Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log: Provide a way to access / substitute the default logger #8918

Closed
gopherbot opened this issue Oct 10, 2014 · 7 comments
Closed

log: Provide a way to access / substitute the default logger #8918

gopherbot opened this issue Oct 10, 2014 · 7 comments

Comments

@gopherbot
Copy link

by fuzxxl:

Right now, the log package provides two ways to log:

First, you can create a log.Logger and call various logging functions on it.
Second, you can directly call functions from the log package with the same API as in the
first case.

It would be great if there was a way to retrieve and substitute the global default
logger, just like it is possible with os.Stdin, os.Stdout, and os.Stderr. This would
make it possible to have functions that operate on a Logger object log to the default
logger and to substitute something else for the default logger, such as a Logger
generated by log.syslog.New().

Implementing this might be as easy as making the already existing log.std variable
visible to the outside.
@ianlancetaylor
Copy link
Contributor

Comment 1:

Labels changed: added repo-main, release-none.

@bradfitz bradfitz removed the new label Dec 18, 2014
@rsc rsc added this to the Unplanned milestone Apr 10, 2015
@agnivade
Copy link
Contributor

agnivade commented Oct 3, 2017

Hi,

Is there any interest in this ?

I can send a CL if so.

@davecheney
Copy link
Contributor

Please discuss your proposed change before sending any code. Thank you.

@agnivade
Copy link
Contributor

agnivade commented Oct 3, 2017

Sure, I wanted to clarify whether I should attempt a change at all in the first place, before discussing how the change will be implemented.

@ianlancetaylor
Copy link
Contributor

@agnivade To decide whether you should attempt a change, I think we need to see a suggested API. At this point I don't quite understand what this issue is asking for. After all, we already have log.SetOutput. What else do we need?

@agnivade
Copy link
Contributor

agnivade commented Oct 3, 2017

That's true actually. I gave it some more thought. The SetOutput covers all the use cases which the OP wants. And along with it, we have SetFlags and SetPrefix. Using these 3, one can effectively replace the standard logger entirely.

I think this issue is moot now.

@ianlancetaylor
Copy link
Contributor

Sounds good to me. Closing. Please comment if you disagree.

@golang golang locked and limited conversation to collaborators Oct 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants