certmagic icon indicating copy to clipboard operation
certmagic copied to clipboard

refactor: replace the file storage logger with the default logger

Open jinrenjie opened this issue 1 year ago • 4 comments

I use certmagic in my project, it's great, but I had trouble collecting logs, so I want to replace log with Default.Logger to make the log style uniform!

jinrenjie avatar Sep 15 '24 19:09 jinrenjie

Thanks; I suppose this is better than using the std lib logger, as it's the "wrong" logger either way (these places don't have a config available to them for us to get the "correct" logger).

Although, Default is intended as a template and shouldn't be used directly. Plus, it could be modified to set Default.Logger to nil. ( :boom: ) We should probably refer to defaultLogger directly if possible. Would that work?

mholt avatar Sep 16 '24 12:09 mholt

@mholt I think Default.Logger is more suitable than defaultLogger, because users can set custom Logger through Default.Logger. In addition, I saw in the code that if Default.Logger is nil, defaultLogger can be assigned to Default.Logger.

jinrenjie avatar Sep 16 '24 13:09 jinrenjie

In addition, I saw in the code that if Default.Logger is nil, defaultLogger can be assigned to Default.Logger

That's only the case if a new instance of a Config is made by using Default as an input (like a template).

defaultLogger is the only zap logger guaranteed to be properly set (non-nil).

mholt avatar Sep 16 '24 15:09 mholt

@mholt I have replaced Default.Logger with defaultLogger.

jinrenjie avatar Sep 19 '24 18:09 jinrenjie

Thanks -- sorry I've been backlogged. This is still on my list just FYI :)

mholt avatar Dec 12 '24 02:12 mholt