Consider changing the default enabled log levels #147
Labels
No labels
bug
duplicate
easy
enhancement
help wanted
invalid
question
rfc
structured-logging
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-rust-lang/log#147
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Right now I believe all log levels are enabled by default in all builds. @sfackler provided some good rationale for this during the evaluation, @sfackler want to copy that down here as well?
In any case would be worth discussing before a 1.0 release!
Bump for this for the missing offline comments. Also, has build-time stubbing of disabled levels (like slog does) been discussed? Is it in scope here?
Oops, sorry!
You can already statically disable levels actually: https://github.com/rust-lang-nursery/log/blob/master/Cargo.toml#L23-L35. The question here is over defaults.
I feel pretty strongly that we shouldn't disable any level of logging by default. The whole point of logging is that you have bunch of diagnostic information available to you when you need it. You normally don't need to look at debug or trace level logging, but when you do it's invaluable! For example, Hyper's trace-level logging helped track down a bug in its chunked request body parser in a running server.
If, for example, trace logging were disabled by default, you'd have several problems. If I ran into that Hyper problem above, I'd have to ship a new custom build of the server with trace logging enabled to actually be able to get the information I need. If the issue you're looking into is one of the annoying transient ones that no-one knows how to reproduce but pops up in production every once in a while, it's really important to be able to look very closely at whatever box it shows up on immediately! I could also override the default to enable trace logging by default, but then I potentially have other issues - if people become too used to trace logging being turned off, you may run into issues where those log events are extremely expensive or even broken! Rustc has some of those issues - the old log framework disabled debug logging in prod builds, and didn't evaluate log arguments if the log event wasn't enabled and it turned out that several would panic if actually evaluated.
In addition, there is a fast path for logging levels that are entirely disabled at runtime. If you don't have any trace-level logging enabled in your logger configuration, the cost of a
trace!statement is a relaxed atomic load, comparison against a constant, and branch. If you're logging so much that that fast path ends up slowing things down significantly, I don't really see how that level of verbosity can possibly be useful.Thanks for the feedback! It looks like my knowledge around here is wrong/stale, so I'm paging @dpc for some informed comment.
I understand @sfackler points, and I think they make sense. I also don't feel strongly about default logging level in
slog. I gave the matter some consideration and picked the defaults.As a library writer, it is convenient to have a logging level for your disposal, that you don't have to feel guilty about using, and comes handy when you are testing and debugging your library while you are working on it, change it etc.. It is not optimal if
hyperis important enough to havetraceinformation, butmysillylibrarymust be cautious or jump through custom macro hoops because it's somehow of lesser category or something like that. So that would be my main concern. I was hoping to get to think about it more, and maybe do some prototyping of something that could satisfy everyone, ideas include:There are some differences between
slogandslogthat change the dynamics a bit:slogsupports lazily evaluated values, so the risk of panics during with logging enabled is inherent. That is kind of OK, becauseslogtreats logging as first class citizen. You need to take care of API changes related to logging, logging logical structure and context etc.Also, because in slog you do compose how the different pices of your software route their logging messages, it is possible to modify in-flight eg. lowering logging levels of your dependencies. Even if they do overuse trace, or debug, and you turned it on, they still wouldn't get logged and their overhead would be minimal.
So in slog, if there's something useful to know in production, no matter how minor it might be from global perspective you can make it an
info. If something is only useful for debugging you make itdebug, and so on. The users of your library can decide how much they care (or typically not care). And you can stuff your code withtracefor your own (maintainer/developer of given library) use, without much worrying about affecting your users.So I don't think
logshould neccesarily copyslogdefaults.For reference, I ended up here today because of such discussions happening around TLS libraries and logging:
I think a concur that all log levels should be compiled in by default. Would be quite surprising for a naive user to deploy an app, go to turn on verbose logs and discover they don't exist.
Probably about time to decide one way or the other here.
cc @sfackler @alexcrichton
I'm personally on board with "compile everything in by default"
Compiling all by default sounds good to me too. Are we happy to close this or would you like to keep it open to solicit some more feedback?
I think we're good to go.