feat: add GetLogLevel and GetAllLogLevels#160
Merged
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
Member
Author
|
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. |
lidel
reviewed
Jul 25, 2025
gammazero
requested changes
Jul 25, 2025
Co-authored-by: Andrew Gillis <11790789+gammazero@users.noreply.github.com>
Co-authored-by: Andrew Gillis <11790789+gammazero@users.noreply.github.com>
Co-authored-by: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com>
gammazero
reviewed
Jul 28, 2025
Co-authored-by: Andrew Gillis <11790789+gammazero@users.noreply.github.com>
Co-authored-by: Andrew Gillis <11790789+gammazero@users.noreply.github.com>
gammazero
approved these changes
Jul 28, 2025
This was referenced Jul 28, 2025
gammazero
requested changes
Jul 28, 2025
levels.go
Outdated
| return zapcore.Level(defLvl).String(), nil | ||
| } | ||
| if lvl, ok := levels[name]; ok { | ||
| return zapcore.Level(LogLevel(lvl.Level())).String(), nil |
Contributor
There was a problem hiding this comment.
Suggested change
| 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() |
Contributor
There was a problem hiding this comment.
Suggested change
| result[name] = zapcore.Level(LogLevel(level.Level())).String() | |
| result[name] = level.Level().String() |
gammazero
approved these changes
Jul 28, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
"","*")