aibrix icon indicating copy to clipboard operation
aibrix copied to clipboard

Build better logging experiences with zap/klogr and structure logging

Open Jeffwan opened this issue 1 year ago • 4 comments

🚀 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 avatar Oct 02 '24 07:10 Jeffwan

@Jeffwan May I take this?

nadongjun avatar Mar 21 '25 02:03 nadongjun

@nadongjun Definitely, thanks for the help. I will assign this one to you.

Jeffwan avatar Mar 21 '25 05:03 Jeffwan

@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 avatar Mar 21 '25 08:03 nadongjun

@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

Jeffwan avatar Mar 21 '25 16:03 Jeffwan