-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
feat: add query functionality to log level command #10885
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
Merged
Merged
Changes from 16 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
40bbd2a
feat: add log get-level command
SgtPooki 44e1119
chore: update changelog
SgtPooki 9839fa4
test: add log get-level tests
SgtPooki 254f5c9
chore: cleanup
SgtPooki 970e687
chore: fix typo and harden tests
lidel c5b7d21
fix: TestCommands
lidel 32c8363
docs: relation to GOLOG_LOG_LEVEL
lidel 5b2597f
chore(go.mod): switch to PR dependency
lidel 8adcf34
chore: update to latest go-log PR changes
SgtPooki 1042bab
fix: GetLogLevel requires an argument
SgtPooki 987d378
fix: do not output single subsystem name in CLI
SgtPooki b7489b9
test: explicit subsystem request dont output subsystem
SgtPooki 0d910d0
update to new release og go-log
gammazero dc2cc3f
Use go-log v2.8.0. Use default keyword to identify default level
gammazero 95835cb
LevelFromString renamed to Parse
gammazero 6990fef
Recognize keywords "all", "default", and "*" when setting log levels
gammazero 3b725d7
Merge branch 'master' into fix/add-api-v0-log--get-level
gammazero 9a6d341
Modify `ipfs log level` to show log levels
gammazero 2ee9c40
Denote default level with sdubsystem name '(defult)'. Fix tests
gammazero a9521a7
fix help formatting
gammazero 0cd62f2
test: extra CLI/RPC tests for examples from --help
lidel 2b5ab33
refactor: restore 'all' alias for '*'
lidel fb0f89d
Merge branch 'master' into fix/add-api-v0-log--get-level
gammazero fefffdb
Merge branch 'master' into fix/add-api-v0-log--get-level
lidel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| package cli | ||
|
|
||
| import ( | ||
| "strings" | ||
| "testing" | ||
|
|
||
| "github.com/ipfs/kubo/test/cli/harness" | ||
| . "github.com/ipfs/kubo/test/cli/testutils" | ||
| "github.com/stretchr/testify/assert" | ||
| ) | ||
|
|
||
| func TestLogGetLevel(t *testing.T) { | ||
|
|
||
| t.Run("get-level shows all subsystems", func(t *testing.T) { | ||
| t.Parallel() | ||
| node := harness.NewT(t).NewNode().Init().StartDaemon() | ||
| defer node.StopDaemon() | ||
|
|
||
| // Get expected subsystem count from 'ipfs log ls' | ||
| lsRes := node.IPFS("log", "ls") | ||
| assert.NoError(t, lsRes.Err) | ||
| expectedSubsystems := len(SplitLines(lsRes.Stdout.String())) | ||
|
|
||
| res := node.IPFS("log", "get-level") | ||
| assert.NoError(t, res.Err) | ||
| assert.Equal(t, 0, len(res.Stderr.Lines())) | ||
|
|
||
| output := res.Stdout.String() | ||
| lines := SplitLines(output) | ||
|
|
||
| // Should show all subsystems plus the global '*' level | ||
| assert.GreaterOrEqual(t, len(lines), expectedSubsystems) | ||
lidel marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| // Check that each line has the format "subsystem: level" | ||
| for _, line := range lines { | ||
| if strings.TrimSpace(line) == "" { | ||
| continue | ||
| } | ||
| parts := strings.Split(line, ": ") | ||
| assert.Equal(t, 2, len(parts), "Line should have format 'subsystem: level', got: %s", line) | ||
| assert.NotEmpty(t, parts[0], "Subsystem should not be empty") | ||
| assert.NotEmpty(t, parts[1], "Level should not be empty") | ||
| } | ||
| }) | ||
|
|
||
| t.Run("get-level with specific subsystem", func(t *testing.T) { | ||
| t.Parallel() | ||
| node := harness.NewT(t).NewNode().Init().StartDaemon() | ||
| defer node.StopDaemon() | ||
|
|
||
| node.IPFS("log", "level", "core", "debug") | ||
| res := node.IPFS("log", "get-level", "core") | ||
| assert.NoError(t, res.Err) | ||
| assert.Equal(t, 0, len(res.Stderr.Lines())) | ||
|
|
||
| output := res.Stdout.String() | ||
| lines := SplitLines(output) | ||
|
|
||
| assert.Equal(t, 1, len(lines)) | ||
|
|
||
| line := strings.TrimSpace(lines[0]) | ||
| assert.Equal(t, "debug", line) | ||
| }) | ||
|
|
||
| t.Run("get-level with 'default' returns default level", func(t *testing.T) { | ||
| t.Parallel() | ||
| node := harness.NewT(t).NewNode().Init().StartDaemon() | ||
| defer node.StopDaemon() | ||
|
|
||
| res1 := node.IPFS("log", "level", "all", "fatal") | ||
| assert.NoError(t, res1.Err) | ||
| assert.Equal(t, 0, len(res1.Stderr.Lines())) | ||
|
|
||
| res := node.IPFS("log", "get-level", "default") | ||
| assert.NoError(t, res.Err) | ||
| assert.Equal(t, 0, len(res.Stderr.Lines())) | ||
|
|
||
| output := res.Stdout.String() | ||
| lines := SplitLines(output) | ||
|
|
||
| assert.Equal(t, 1, len(lines)) | ||
|
|
||
| line := strings.TrimSpace(lines[0]) | ||
| assert.Equal(t, "fatal", line) | ||
| }) | ||
|
|
||
| t.Run("get-level reflects runtime log level changes", func(t *testing.T) { | ||
| t.Parallel() | ||
| node := harness.NewT(t).NewNode().Init().StartDaemon("--offline") | ||
| defer node.StopDaemon() | ||
|
|
||
| node.IPFS("log", "level", "core", "debug") | ||
| res := node.IPFS("log", "get-level", "core") | ||
| assert.NoError(t, res.Err) | ||
|
|
||
| output := res.Stdout.String() | ||
| lines := SplitLines(output) | ||
|
|
||
| assert.Equal(t, 1, len(lines)) | ||
|
|
||
| line := strings.TrimSpace(lines[0]) | ||
| assert.Equal(t, "debug", line) | ||
| }) | ||
|
|
||
| t.Run("get-level with non-existent subsystem returns error", func(t *testing.T) { | ||
| t.Parallel() | ||
| node := harness.NewT(t).NewNode().Init().StartDaemon() | ||
| defer node.StopDaemon() | ||
|
|
||
| res := node.RunIPFS("log", "get-level", "non-existent-subsystem") | ||
| assert.Error(t, res.Err) | ||
| assert.NotEqual(t, 0, len(res.Stderr.Lines())) | ||
| }) | ||
|
|
||
| } | ||
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.