-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Log levels change #7414
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?
Log levels change #7414
Conversation
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.
Pull Request Overview
This PR changes the log level ordering to follow a descending scale so that lower numerical values represent more verbose logging. Key changes include:
- Explicit log level constant assignments (Silent = 12, Error = 8, Warn = 4, Info = 0).
- Reversal of log condition comparisons in the Info, Warn, Error, and Trace methods.
- Adjustments in the Trace method to correctly gate logging based on the new descending log level order.
@@ -135,21 +135,21 @@ func (l *logger) LogMode(level LogLevel) Interface { | |||
|
|||
// Info print info | |||
func (l *logger) Info(ctx context.Context, msg string, data ...interface{}) { | |||
if l.LogLevel >= Info { | |||
if l.LogLevel <= Info { |
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.
Consider adding a comment here to clarify that the reversed comparison (<=) is used because lower numerical values indicate higher verbosity.
Copilot uses AI. Check for mistakes.
@@ -158,28 +158,28 @@ func (l *logger) Error(ctx context.Context, msg string, data ...interface{}) { | |||
// | |||
//nolint:cyclop | |||
func (l *logger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error) { | |||
if l.LogLevel <= Silent { | |||
if l.LogLevel >= Silent { |
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.
Consider adding a comment to explain that logging is skipped when the logger's level is set to Silent or higher, following the new descending order.
Copilot uses AI. Check for mistakes.
@@ -36,13 +36,13 @@ type LogLevel int | |||
|
|||
const ( | |||
// Silent silent log 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 did you change it to a fixed number instead of just reordering them?
What did this pull request do?
Almost every logger's log levels is descending so i decided to change Gorm's levels too since I had problems configuring slog with it.
User Case Description