jozu-ai / kitops

Tools for easing the handoff between AI/ML and App/SRE teams.
https://KitOps.ml
Apache License 2.0
266 stars 26 forks source link

Add different log-levels to output; name per-request trace logging for registry operations #339

Closed amisevsk closed 3 weeks ago

amisevsk commented 3 weeks ago

Description

Add support for multiple log levels (error, warn, info, debug, and trace) with a corresponding flag --log-level. The old -v | --verbose flag is left in place for convenience. Currently, the only 'trace' level logging is per-request info while pushing/pulling a registry. Also, if the log-level is not info, we output a prefix indicating log level for each line, to make it a little more readable.

2024-06-06-11:49:33 2024-06-06-11:58:30

If the log-level is 'info", the output is unchanged.

Linked issues

Closes #338

amisevsk commented 3 weeks ago

There's some oddness in the color selections -- I'd ideally like [TRACE] to be a dim grey, but some color themes (looking at you, solarized on gnome terminal) use the same color for background and "dark grey" making it invisible.

amisevsk commented 3 weeks ago

I kind of wish we could implement a Logger struct that encapsulate and abstract away this.

I agree, though at this point, that's basically what we've done -- the struct would just encapsulate what are now package globals :shrug:

I can open a follow-up PR to clean it up a little. The cleanest in-package solution would be to do away with info, debug, error functions and just use log(LEVEL, ...) but that makes every invocation a little messier