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: Logger struct does not export a SetOutput method #9629

Closed
driskell opened this issue Jan 18, 2015 · 4 comments
Closed

log: Logger struct does not export a SetOutput method #9629

driskell opened this issue Jan 18, 2015 · 4 comments

Comments

@driskell
Copy link

What version of Go are you using (go version)?
1.4

What operating system and processor architecture are you using?
Mac OS X Intel x86_64

What did you do?
Attempt to call SetOutput on a Logger.

What did you expect to see?
The method to exist and work.

What did you see instead?
The method does not exist.

Background
I require a way to reopen the output log file. I can do this with the default Logger by creating a new file handle and calling the SetOutput exported module function, which exists and works. I then close the previous file handle. Unfortunately there is no direct way to do this for a custom Logger created by the exported function New as it does not export a SetOutput method. The only way is indirectly with a custom io.Writer and its own mutex to control the switch. This means extraneous code though and having two mutex for the same purpose (synchronising handle access) is undesirable. Granted, performance hit would be negligible in most apps but I can see it impacting anything relying on fastest logging possible (web server access logs?)

Either way, a simple export of SetOutput for custom Loggers using the internal mutex only would be perfect. If it's agreeable but time is sparse I can make the patch required.

Jason

@mattn
Copy link
Member

mattn commented Jan 19, 2015

+1

will be possible to output logs with color on windows. https://github.com/mattn/go-colorable

@adg
Copy link
Contributor

adg commented Jan 19, 2015

@driskell
Copy link
Author

@adg that looks great and exactly what I needed, thank you!
If you need anything from me, please do let me know. Otherwise, I look forward to review completion and hopefully acceptance 👍

@adg
Copy link
Contributor

adg commented Jan 20, 2015

Just waiting on @robpike's review.

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

4 participants