natefinch / lumberjack

lumberjack is a log rolling package for Go
MIT License
4.81k stars 593 forks source link

Fallback writer in case of error #191

Open mholt opened 1 year ago

mholt commented 1 year ago

Hi Nate,

Thanks again for Lumberjack. Been using it for years now in Caddy!

We have some users (including myself, heh) who have incorrect permissions on their log folder/files. This leads to errors like write error: error getting log file info in the logs, but the actual log message is lost to oblivion. :sweat_smile:

Since Lumberjack hides the underlying io.Writer, I can't figure out a way to wrap the Write() method and, if there's an error, dump the log message to stderr as a fallback.

Would this be a feature you could support?

It would be very helpful if we didn't lose log messages on an external issue like permissions.

Thanks!

natefinch commented 1 year ago

Hi Matt! This is a tricky one. This sounds like something that should be addressed for v3, which uses a constructor method specifically to do some sanity checks on startup.

What's your timeline for getting this done?

mholt commented 1 year ago

Sounds good to me. It's not urgent. Over the years we've had a number of questions about this, so I've learned it's not an isolated problem for sysadmins to have the wrong permissions configured. :sweat_smile:

Thank you for Lumberjack