Build better logging experiences with zap/klogr and structure logging
🚀 Feature Description and Motivation
-
Option 1: zap (native solution), good for structure logging
-
Option 2: klogr + klog - most simplest solution with minimum changes
no need to change the klog reference in the controller codes, append --v=4 will show the debug level messages.
klog.InitFlags(flag.CommandLine)
defer klog.Flush()
flag.Parse()
ctrl.SetLogger(klogr.New())
- Option 3: klogr textlogger
logConfig := textlogger.NewConfig(
textlogger.Verbosity(4),
textlogger.Output(os.Stdout))
ctrl.SetLogger(textlogger.NewLogger(logConfig))
in this case, textlogger.Verbosity(4) won't show klog.V(4), there're still separate. We should use ctrl.Log.V(4).Info
Use Case
No response
Proposed Solution
No response
@Jeffwan May I take this?
@nadongjun Definitely, thanks for the help. I will assign this one to you.
@Jeffwan Thank you! I'm not very familiar with the code, so it might take some time, but I'll try to do it as quickly as possible.
@nadongjun not a problem at all, feel free to join slack channel or just post problem here if you need any help. this is not urgent