-
Notifications
You must be signed in to change notification settings - Fork 628
feat: add logging levels and slog based logging #1714
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
base: main
Are you sure you want to change the base?
Conversation
|
First of all my bad, I didn't run the test locally. After checking it on my branch (feat/logging) and on a clean clone of main, it consistently fails in both places. It’s also the only test that fails across all CI runs. can you guide me a little bit ? how to resolve this. |
|
@kavirajk Thanks for your feedback I have reworked the implementation and updated a few things Initial approachLogLevel slog.Level But this would cause ambiguity in the special case you highlighted: when both legacy debug options and the new LogLevel are set, as even if user does not set LogLevel it defaults to zero value and it is basically equal to This ambiguity disables us from distinguishing between these case:
This happens because a bare Other Feasible Approaches1. Use a Pointer Level to Distinguish Unset from Set (Implemented)LogLevel *slog.Level level := slog.LevelDebug
conn, err := clickhouse.Open(&clickhouse.Options{
Addr: []string{"127.0.0.1:9000"},
Auth: clickhouse.Auth{
Database: "default",
Username: "default",
Password: "pass",
},
LogLevel: &level,
})
2. String-enum approachSet up a public surface type LogLevel string
const (
LevelDebug LogLevel = "debug"
LevelInfo LogLevel = "info"
LevelWarn LogLevel = "warn"
LevelError LogLevel = "error"
)Client setup conn, err := clickhouse.Open(&clickhouse.Options{
Addr: []string{"127.0.0.1:9000"},
Auth: ...,
LogLevel: clickhouse.LevelDebug,
})Will require String-to- Please let me know what you think. Thank you! |
|
@kavirajk I have added the required methods in the new test. |
|
@pkalsi97 I'm taking a look at it. Adding few changes on top of yours to avoid lots of duplicate logging. |
|
@kavirajk thank for looking into this. If you could just point out what changes are needed. I'll implement. |
Summary
This PR introduces slog based logging (Issue #1698)
INFO|DEBUG|WARN|ERRORDebugandDebugf.Both replaced by
LogLevelfor unified level-based logging.Creates a ClickHouse client using given address/auth credentials and enables debug-level logging.
Note: By default logging is set to
slog.LevelInfoLastly, this is an initial iteration; I want maintainer's direct feedback on any required changes so I can apply them.
Sample Logs for refrence