Skip to content

Conversation

@jinrenjie
Copy link
Contributor

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!

@mholt
Copy link
Member

mholt commented Sep 16, 2024

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. ( 💥 ) We should probably refer to defaultLogger directly if possible. Would that work?

@jinrenjie
Copy link
Contributor Author

@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.

@mholt
Copy link
Member

mholt commented Sep 16, 2024

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).

Replace Default.Logger with defaultLogger
@jinrenjie
Copy link
Contributor Author

@mholt I have replaced Default.Logger with defaultLogger.

@mholt
Copy link
Member

mholt commented Dec 12, 2024

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

@mholt mholt merged commit 476582b into caddyserver:master Jun 5, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants