Skip to content

converting inline log to slog#30603

Merged
mattfarina merged 9 commits intohelm:mainfrom
robertsirc:converting-to-slog
Mar 21, 2025
Merged

converting inline log to slog#30603
mattfarina merged 9 commits intohelm:mainfrom
robertsirc:converting-to-slog

Conversation

@robertsirc
Copy link
Copy Markdown
Member

I converted inline log to slog. This is my first pass there will be more when i jump into other sections.

Signed-off-by: Robert Sirchia <rsirchia@outlook.com>
@pull-request-size pull-request-size bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Feb 27, 2025
Signed-off-by: Robert Sirchia <rsirchia@outlook.com>
Signed-off-by: Robert Sirchia <rsirchia@outlook.com>
Signed-off-by: Robert Sirchia <rsirchia@outlook.com>
Signed-off-by: Robert Sirchia <rsirchia@outlook.com>
@robertsirc robertsirc requested a review from TerryHowe February 28, 2025 21:20
Copy link
Copy Markdown
Contributor

@TerryHowe TerryHowe left a comment

Choose a reason for hiding this comment

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

Normal logging, I would expect the messages to start with an uppercase character, but with structured logging, I'm not sure. It seems like most of the existing messages start with a lower case charactger.

Copy link
Copy Markdown
Collaborator

@mattfarina mattfarina left a comment

Choose a reason for hiding this comment

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

Note: I was looking up if log messages should start with an uppercase or lowercase letter. There is no consistency here. Even in the Go standard library. Projects like Kubernetes are also inconsistent.

Signed-off-by: Robert Sirchia <rsirchia@outlook.com>
Signed-off-by: Robert Sirchia <rsirchia@outlook.com>
Copy link
Copy Markdown
Contributor

@TerryHowe TerryHowe left a comment

Choose a reason for hiding this comment

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

/lgtm

@robertsirc robertsirc requested a review from mattfarina March 8, 2025 21:10
Copy link
Copy Markdown
Collaborator

@mattfarina mattfarina left a comment

Choose a reason for hiding this comment

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

I noticed that errors are sometimes keyed as "err" and other times keyed as "error". Can we please have this be consistent with "error"?

Signed-off-by: Robert Sirchia <rsirchia@outlook.com>
@robertsirc
Copy link
Copy Markdown
Member Author

I noticed that errors are sometimes keyed as "err" and other times keyed as "error". Can we please have this be consistent with "error"?

I addressed this for you as well.

vv, err := cvals.Table(r.Name + "." + child)
if err != nil {
log.Printf("Warning: ImportValues missing table from chart %s: %v", r.Name, err)
slog.Warn("ImportValues missing table from chart", "chart", r.Name, "value", err)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should it be "error" instead of "value"

if e.LintMode {
// Don't fail on missing required values when linting
log.Printf("[INFO] Missing required value: %s", warn)
slog.Warn("missing required value", "value", warn)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In this case the warn is a message that's shared with the template executor when the required thing is not present. So, the key name could be something like message.

if e.LintMode {
// Don't fail on missing required values when linting
log.Printf("[INFO] Missing required value: %s", warn)
slog.Warn("missing required values", "value", warn)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In this case the warn is a message that's shared with the template executor when the required thing is not present. So, the key name could be something like message.

if e.LintMode {
// Don't fail when linting
log.Printf("[INFO] Fail: %s", msg)
slog.Info("funcMap fail", "lintMode", msg)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

message also makes sense as a key name here. That's what's being passed.

resList, err := discoveryClient.ServerResourcesForGroupVersion(gvk.GroupVersion().String())
if err != nil {
log.Printf("[ERROR] unable to retrieve resource list for: %s , error: %s", gvk.GroupVersion().String(), err)
slog.Error("unable to retrieve resource list", "list", gvk.GroupVersion().String(), "error", err)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Instead of list for the key, it should be GroupVersion.

Signed-off-by: Robert Sirchia <rsirchia@outlook.com>
@mattfarina mattfarina merged commit ab9f0c8 into helm:main Mar 21, 2025
5 checks passed
@benoittgt benoittgt mentioned this pull request Mar 25, 2025
3 tasks
@scottrigby scottrigby added this to the 4.0.0 milestone Nov 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants