Skip to content
This repository was archived by the owner on Jan 13, 2026. It is now read-only.

Replace logrus by klog#4180

Merged
antgamdia merged 3 commits into
mainfrom
unifyImports-3.3
Jan 31, 2022
Merged

Replace logrus by klog#4180
antgamdia merged 3 commits into
mainfrom
unifyImports-3.3

Conversation

@antgamdia
Copy link
Copy Markdown
Contributor

Description of the change

This PR continues the effort started some time ago in unifying the logging libraries. We opted for klog, the one used in Kubernetes. Some minor changes have been introduced in order to adapt the log operations to the ones available in klog (no WithParams or WithError are available here).

Benefits

Reduce same-purpose deps. It also simplifies the task of moving to structured logging as we were asked in the past.

Possible drawbacks

N/A

Applicable issues

Additional information

N/A

func chartImportWorker(repoURL *url.URL, r *OCIRegistry, chartJobs <-chan pullChartJob, resultChan chan pullChartResult) {
for j := range chartJobs {
log.WithFields(log.Fields{"name": j.AppName, "tag": j.Tag}).Debug("pulling chart")
log.V(4).Infof("pulling chart, name=%s, tag=%s", j.AppName, j.Tag)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use klog's support for structured logging here and above, with something like:

Suggested change
log.V(4).Infof("pulling chart, name=%s, tag=%s", j.AppName, j.Tag)
log.V(4).InfoS("pulling chart", "name", j.AppName, "tag", j.Tag)

or even

Suggested change
log.V(4).Infof("pulling chart, name=%s, tag=%s", j.AppName, j.Tag)
log.V(4).InfoS("pulling chart", "chartJob", j)

Better eg showing the difference: https://go.dev/play/p/EW5ZQh7MDXI

Or maybe you want to do that separately so it's consistent across the codebase (personally I'd think it OK to do it as we update, like here, but up to you).

Copy link
Copy Markdown
Contributor Author

@antgamdia antgamdia Jan 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion and the playground example. I haven't given it a try yet. Really interesting.

As per #3848 (comment), I already have planned to do so in a separate PR once this stack of PRs became merged. I've added a card to our board not to forget about it. I've created an issue.

Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>
Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>
@antgamdia antgamdia changed the base branch from unifyImports-2 to main January 31, 2022 16:31
Signed-off-by: Antonio Gamez Diaz <agamez@vmware.com>

Conflicts:
	cmd/apprepository-controller/cmd/root.go
	cmd/asset-syncer/cmd/root.go
	cmd/asset-syncer/server/utils.go
	cmd/assetsvc/cmd/root.go
	cmd/kubeapps-apis/cmd/root.go
	pkg/agent/docker_secrets_postrenderer.go
@antgamdia antgamdia merged commit a7f1563 into main Jan 31, 2022
@antgamdia antgamdia deleted the unifyImports-3.3 branch January 31, 2022 17:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants