clickhouse-go icon indicating copy to clipboard operation
clickhouse-go copied to clipboard

Logging: Support logging levels

Open kavirajk opened this issue 1 month ago • 3 comments

Currently we only have debug=true to have unstructured log lines on the stdout. We would like to have

  1. Structured logging
  2. Basic log levels (INFO, DEBUG, ERROR)

kavirajk avatar Nov 04 '25 08:11 kavirajk

@kavirajk I'm new to open source and would love to contribute. Can you provide more details on how to implement this feature this? Any guidance on how to get started would be really helpful!

HarshMehta112 avatar Nov 10 '25 09:11 HarshMehta112

@HarshMehta112 Sure.

Here is how I envision. Currently we just use simple fmt.Println based logging everywhere (example). Which is lacking two things.

  1. It's not structured. Better to have some structured key=value pairs in the long line. e.g: error="connection failed" cause="address already in use", or query="select 1" took=2ms transport=http.
  2. No log levels. Currently it's just either Debug=true|false. Would be nice to have debug level to print corresponding logs when needed without noise.

I planned to use slog package to solve both the problem. You can read about it here. https://go.dev/blog/slog

Basically, the end-result would be something like clickhouse.Options accepting option LogLevel: INFO|DEBUG|ERROR and depricate Debug: true|false option and use slog to solve the two problems I mentioned above.

kavirajk avatar Nov 10 '25 10:11 kavirajk

@kavirajk I have raise a PR regarding this, Please provide input or corrections you consider necessary; I’ll apply them and continue refining the work.

pkalsi97 avatar Nov 18 '25 13:11 pkalsi97