-
-
Notifications
You must be signed in to change notification settings - Fork 629
feat(logging): Switch to slog library #1472
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
f847af9 to
d71ecf4
Compare
d71ecf4 to
9bbdf76
Compare
| } | ||
| } | ||
| logr.Debugf("[security.callbackHandler] Subject %s is not in the list of allowed subjects", idToken.Subject) | ||
| slog.Debug("Subject not in allow-list", "subject", idToken.Subject) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: Improve debug message to give more context -> What allow-list?
| } | ||
| s.suiteCache.Set(suiteKey, status) | ||
| logr.Debugf("[memory.InsertSuiteResult] Stored suite result for suiteKey=%s, total results=%d", suiteKey, len(status.Results)) | ||
| slog.Debug("Stored suite result", "key", suiteKey, "total_results", len(status.Results)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: Improve message?
| parsedDuration, err := time.ParseDuration(c.Query("duration")) | ||
| if err != nil { | ||
| logr.Errorf("[api.CreateExternalEndpointResult] Invalid duration from string=%s with error: %s", c.Query("duration"), err.Error()) | ||
| slog.Error("Invalid duration", "duration", c.Query("duration"), "error", err.Error()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: More message context needed?
| return c.Status(500).SendString(err.Error()) | ||
| } | ||
| logr.Infof("[api.CreateExternalEndpointResult] Successfully inserted result for external endpoint with key=%s and success=%s", c.Params("key"), success) | ||
| slog.Info("Successfully inserted result for external endpoint", slog.Group("result", "key", c.Params("key"), "success", success)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: Remove group test or apply in other places too?
logging/logging.go
Outdated
| "INFO": slog.LevelInfo, | ||
| "WARN": slog.LevelWarn, | ||
| "ERROR": slog.LevelError, | ||
| "FATAL": slog.LevelError, // slog does not have Fatal level, using Error instead TODO#1185: Check feasibility adding custom level FATAL to log handler or deprecate since its only used twice? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it ok that fatal log level does not exist anymore? I checked and it is possible to add custom levels, but it would obviously be convenient if we could just use the default ones.
logging/logging.go
Outdated
| switch logSourceAsString { | ||
| case "", "FALSE": | ||
| break | ||
| case "TRUE": | ||
| logHandlerOptions.AddSource = true | ||
| default: | ||
| slog.Warn("Invalid log source value, defaulting to false", "provided", logSourceAsString) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this approach to disable source location logging by default and only enable different levels of verbosity for it via the GATUS_LOG_SOURCE and GATUS_LOG_TYPE env vars?
storage/store/store.go
Outdated
| if !initialized { | ||
| // This only happens in tests | ||
| logr.Info("[store.Get] Provider requested before it was initialized, automatically initializing") | ||
| slog.Info("Provider requested before it was initialized, automatically initializing") // TODO#1185 Why was/is this not warn level? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not warn level?
Summary
Closes #1185
Checklist
README.md, if applicable.