You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
@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 👍
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
The text was updated successfully, but these errors were encountered: