-
Notifications
You must be signed in to change notification settings - Fork 111
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
all: avoid passing logger to methods #1968
base: stage
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gj, we should do this code-wide :)
@y0sher I did it code-wide, although I might have missed something. Anyway, we'll be able to fix leftovers if we find them. Please review it again |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files☔ View full report in Codecov by Sentry. |
# Conflicts: # operator/duties/scheduler.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, these are certainly great changes!
An alternative approach could be having a separate logger
package that encapsulates Zap and is loaded as a package (rather than being injected through a constructor or function/method).
Something like this:
package logger
import "go.uber.org/zap"
var logger = zap.L()
func Info(msg string, fields ...zap.Field) {
logger.Info(msg, fields...)
}
And the usage:
package main
import "github.com/ssvlabs/utils/logger"
func main() {
logger.Info("Hello, world!")
}
However, if we want to have named loggers at the object level or loggers with additional properties applicable to all log records, we would likely still need to inject it through a constructor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good stuff!
as per title