-
-
Notifications
You must be signed in to change notification settings - Fork 342
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
ref!: adopt log/slog + other prom configs, drop custom logging pkg #1586
Conversation
I would call this a breaking change, as there are updates to command line flag interactions. Changes included: - convert `--debug` bool flag -> `--log.level` string flag. this aligns with prom conventions. This project uses urfave/cli for application commands/flags rather than kingpin as other go packages do, so I couldn't use the promslog/flag pkg directly. Rather, I use our upstream promslog/kingpin configs in the configs we pass here for urfave/cli. We can decide to move off urfave/cli and/or adopt kingpin in the future. - removes `pkg/logging` in favor of using `prometheus/common/promslog`. A small utility function is included in main to simplify some boilerplate with logger initialization, since we instantiate in main in a few places. All functions have been converted to accept/use *slog.Loggers rather than the custom logger interface. - the removal of the custom logging pkg also removes the `IsDebugEnabled()` method, but this is fine because the logger is leveled; debug logs will not print unless `--log.level debug` is passed at the command line, there is no need to check if debug is enabled at log time in the vast majority of cases. - Updates tests as needed; updates nop loggers, test signatures that used `IsDebugEnabled()`, etc. - enable sloglint in golangci-lint, remove go-kit/log configs Signed-off-by: TJ Hoplock <[email protected]>
Thanks, we'll probably slowly convert over other things like |
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.
Great work!
Looking into the config verification failure in tests |
Code was totally valid, but it was setting the format twice. Intention is to set the level. 🤦 Prevents panics when using the logger due to level being nil: https://github.com/prometheus-community/yet-another-cloudwatch-exporter/actions/runs/12147649411/job/33881684148?pr=1586 Signed-off-by: TJ Hoplock <[email protected]>
Signed-off-by: TJ Hoplock <[email protected]>
Alright, I fixed up the verification test; panic was caused by a typo/wrong variable reference. Sorted out now 👍 |
Bump, lemme know if there's any other feedback 👍 |
Thanks! |
I would call this a breaking change, as there are updates to command line flag interactions.
Changes included:
--debug
bool flag ->--log.level
string flag. this aligns with prom conventions. This project uses urfave/cli for application commands/flags rather than kingpin as other go packages do, so I couldn't use the promslog/flag pkg directly. Rather, I use our upstream promslog/kingpin configs in the configs we pass here for urfave/cli. We can decide to move off urfave/cli and/or adopt kingpin in the future.pkg/logging
in favor of usingprometheus/common/promslog
. A small utility function is included in main to simplify some boilerplate with logger initialization, since we instantiate in main in a few places. All functions have been converted to accept/use *slog.Loggers rather than the custom logger interface.IsDebugEnabled()
method, but this is fine because the logger is leveled; debug logs will not print unless--log.level debug
is passed at the command line, there is no need to check if debug is enabled at log time in the vast majority of cases.IsDebugEnabled()
, etc.