-
Notifications
You must be signed in to change notification settings - Fork 54
feat: add GetLogLevel and GetAllLogLevels #160
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
This comment was marked as resolved.
This comment was marked as resolved.
SgtPooki
left a comment
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.
self review
|
I posted some questions on the Kubo PR about how we want to handle global going forward. I didn't want to change it in this PR by default, but if we have updated the global setting, it should make sure new loggers are using that setting rather than the “default” that, currently in this PR, is only the basic starting level for logs.. But, I guess it could be viewed as better either way. |
Co-authored-by: Andrew Gillis <[email protected]>
Co-authored-by: Andrew Gillis <[email protected]>
SgtPooki
left a comment
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.
self review
Co-authored-by: Russell Dempsey <[email protected]>
Co-authored-by: Andrew Gillis <[email protected]>
Co-authored-by: Andrew Gillis <[email protected]>
levels.go
Outdated
| return zapcore.Level(defLvl).String(), nil | ||
| } | ||
| if lvl, ok := levels[name]; ok { | ||
| return zapcore.Level(LogLevel(lvl.Level())).String(), nil |
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.
| return zapcore.Level(LogLevel(lvl.Level())).String(), nil | |
| return lvl.Level().String(), nil |
levels.go
Outdated
|
|
||
| // Add all subsystem levels | ||
| for name, level := range levels { | ||
| result[name] = zapcore.Level(LogLevel(level.Level())).String() |
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.
| result[name] = zapcore.Level(LogLevel(level.Level())).String() | |
| result[name] = level.Level().String() |
Add Log Level Retrieval Functionality
Summary
Added functionality to track and retrieve current log levels (global and per-subsystem) to improve debugging capabilities.
Related ipfs/kubo#10882
Fixes #159
Changes
New Functions
GetLogLevel(names string) (LogLevel, error)""or"*"ErrNoSuchLoggerfor non-existent subsystemsGetAllLogLevels() map[string]LogLevel"*"key for default/global levelKey Features
loggerMutexfor concurrent accessSetLogLevel()Usage Examples
Testing
Added comprehensive tests covering:
"","*")