-
-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC] Logging improvements #655
Comments
Today I learned that error joining and unwrapping was added in go |
watching this now... |
Agree. A PR should be made to amend these to either return the error (with context if possible) or log them to the
This one is a bit harder to implement generally. Debug-level logging should be added where useful and necessary. My go-to method is to add debug-level logging in whatever code I'm working in as needed (rather than trying to add debug level logging everywhere at once).
Agree. This can be done pretty easily.
I don't really see an issue with this. Configuration errors as far as I can tell should cause a panic during the initialisation process, which should give enough information for the user to fix the issues with the config.
Not a huge issue. It works and afaik isn't causing any major issues. In stash I generalised the public logger interface and made the implementation in an internal package and initialised it during startup. I think this is fairly low priority though.
As mentioned at the top, where an error only needs to be logged, then it should generally be logged at the error log-level. Each instance however should be assessed as to whether it should only be logging or whether it should be kicking the error up the chain to be handled upstream. |
If favicon fetching or serving fails for any reason, or if favicon_path is not configured, log an error. Related to stashapp#655
* add error propagation and logging in favicon-related functions If favicon fetching or serving fails for any reason, or if favicon_path is not configured, log an error. Related to #655 * add lint to default make target to conform with GitHub workflow * change error string to conform to linter
…app#659) * add error propagation and logging in favicon-related functions If favicon fetching or serving fails for any reason, or if favicon_path is not configured, log an error. Related to stashapp#655 * add lint to default make target to conform with GitHub workflow * change error string to conform to linter
Problem
Currently the
stash-box
code is littered with these error handling conditionals that fail silently, without propagating the error through the return and without logging.As a result, investigating even the simplest failures in production is difficult. (e.g. was an email sent or did it fail? Why are favicons not saved when I create a site? etc...)
Instead, all these failures should be logged.
Current situation
stash-box
currently has a logger package package. But it has several issues:It's not used very much. These are all the instances where it is used.
It's partially undocumented. The logFile and logLevel config options are not documented in the README.md.
Logger is initialized after the config file is parsed, so configuration errors are logged with the
errors
package from the standard library.stash-box/pkg/manager/manager.go
Lines 33 to 44 in 914f67b
Logger is built around github.com/sirupsen/logrus which is no longer being developed. There are likely better packages for structured logging, some of which are recommended in logrus' README.
Solutions?
The simplest thing would be to start adding
logger.Debug()
calls in all those error handling conditionals throughout the code. But, one problem I noticed is that there's no call trace with this approach which makes it difficult to understand the context of the error.This is something that friendsofgo/errors accomplices with theirEDIT: This is now part of the errors package of the go standard library.Wrap
method.EDIT2: There have also been improvements to the log package of the standard library.
I'm no expert in Go's logging options so I don't feel confident in proposing a solution yet. But I am interested in helping improve the logging situation. Therefore, I would appreciate any pointers for how to go about this.
The text was updated successfully, but these errors were encountered: