-
Notifications
You must be signed in to change notification settings - Fork 3.4k
operator: Convert logrus to slog #35567
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
Conversation
/test |
aceb33d
to
6ca7d7f
Compare
/test |
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.
contributing change lgtm; minor nit when glancing through code
Signed-off-by: Tam Mach <tam.mach@cilium.io>
6ca7d7f
to
9fc8e03
Compare
/test |
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.
Seems good for my CODEOWNERS
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.
Nice, thanks! 🚀
@@ -8,4 +8,4 @@ import ( | |||
"github.com/cilium/cilium/pkg/logging/logfields" | |||
) | |||
|
|||
var log = logging.DefaultLogger.WithField(logfields.LogSubsys, "watchers") | |||
var log = logging.DefaultSlogLogger.With(logfields.LogSubsys, "watchers") |
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.
@sayboras This appears not to correctly respect the settings (e.g., debug log), because the default logger is completely replaced (rather than being mutated) during the configuration phase:
Lines 77 to 88 in 91a844c
switch logFormat { | |
case LogFormatJSON, LogFormatJSONTimestamp: | |
DefaultSlogLogger = slog.New(slog.NewJSONHandler( | |
writer, | |
&opts, | |
)) | |
case LogFormatText, LogFormatTextTimestamp: | |
DefaultSlogLogger = slog.New(slog.NewTextHandler( | |
writer, | |
&opts, | |
)) | |
} |
Could you please take a look?
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.
Ah thanks, let me double check
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.
Argh, yeah, I committed that crime originally; I should have caught this. IIRC the idea was that you're supposed to use the slog.Logger provided by hive, which would then be a stable reference
(the problem is that slog doesn't allow you to mutate the logger)
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.
Yeah, I guess the tricky part is for the modules that have not yet been converted to hive yet. I wonder whether it could make sense to maybe unexport that variable (and provide a safer getter if necessary) to prevent potentially storing a reference to the uninitialized version.
As highlighted in below comment, the default logger is completely replaced (rather than being mutated) during the configuration phase, so we should avoid using global slog instance. Relates: #35567 Reported-by: Marco Iorio <marco.iorio@isovalent.com> Signed-off-by: Tam Mach <tam.mach@cilium.io>
As highlighted in below comment, the default logger is completely replaced (rather than being mutated) during the configuration phase, so we should avoid using global slog instance. Relates: #35567 Reported-by: Marco Iorio <marco.iorio@isovalent.com> Signed-off-by: Tam Mach <tam.mach@cilium.io>
As highlighted in below comment, the default logger is completely replaced (rather than being mutated) during the configuration phase, so we should avoid using global slog instance. Relates: #35567 Reported-by: Marco Iorio <marco.iorio@isovalent.com> Signed-off-by: Tam Mach <tam.mach@cilium.io>
As highlighted in below comment, the default logger is completely replaced (rather than being mutated) during the configuration phase, so we should avoid using global slog instance. Relates: #35567 Reported-by: Marco Iorio <marco.iorio@isovalent.com> Signed-off-by: Tam Mach <tam.mach@cilium.io>
No description provided.