Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
40bbd2a
feat: add log get-level command
SgtPooki Jul 24, 2025
44e1119
chore: update changelog
SgtPooki Jul 24, 2025
9839fa4
test: add log get-level tests
SgtPooki Jul 24, 2025
254f5c9
chore: cleanup
SgtPooki Jul 24, 2025
970e687
chore: fix typo and harden tests
lidel Jul 24, 2025
c5b7d21
fix: TestCommands
lidel Jul 24, 2025
32c8363
docs: relation to GOLOG_LOG_LEVEL
lidel Jul 25, 2025
5b2597f
chore(go.mod): switch to PR dependency
lidel Jul 25, 2025
8adcf34
chore: update to latest go-log PR changes
SgtPooki Jul 28, 2025
1042bab
fix: GetLogLevel requires an argument
SgtPooki Jul 28, 2025
987d378
fix: do not output single subsystem name in CLI
SgtPooki Jul 28, 2025
b7489b9
test: explicit subsystem request dont output subsystem
SgtPooki Jul 28, 2025
0d910d0
update to new release og go-log
gammazero Jul 29, 2025
dc2cc3f
Use go-log v2.8.0. Use default keyword to identify default level
gammazero Jul 30, 2025
95835cb
LevelFromString renamed to Parse
gammazero Jul 30, 2025
6990fef
Recognize keywords "all", "default", and "*" when setting log levels
gammazero Jul 31, 2025
3b725d7
Merge branch 'master' into fix/add-api-v0-log--get-level
gammazero Aug 6, 2025
9a6d341
Modify `ipfs log level` to show log levels
gammazero Aug 6, 2025
2ee9c40
Denote default level with sdubsystem name '(defult)'. Fix tests
gammazero Aug 6, 2025
a9521a7
fix help formatting
gammazero Aug 6, 2025
0cd62f2
test: extra CLI/RPC tests for examples from --help
lidel Aug 6, 2025
2b5ab33
refactor: restore 'all' alias for '*'
lidel Aug 6, 2025
fb0f89d
Merge branch 'master' into fix/add-api-v0-log--get-level
gammazero Aug 11, 2025
fefffdb
Merge branch 'master' into fix/add-api-v0-log--get-level
lidel Aug 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions core/commands/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ const logLevelOption = "log-level"
var logTailCmd = &cmds.Command{
Status: cmds.Experimental,
Helptext: cmds.HelpText{
Tagline: "Read and outpt log messages.",
Tagline: "Read and output log messages.",
ShortDescription: `
Outputs log messages as they are generated.

Expand Down Expand Up @@ -152,7 +152,13 @@ var logGetLevelCmd = &cmds.Command{
Helptext: cmds.HelpText{
Tagline: "Get the current logging level.",
ShortDescription: `
Get the current logging level for a specific subsystem or all subsystems.
'ipfs log get-level' is a utility command used to get the current logging
level for a specific subsystem or all subsystems.

Examples:
ipfs log get-level # Show levels for all subsystems
ipfs log get-level all # Show the global default level
ipfs log get-level core # Show the core subsystem level
`,
},

Expand Down
12 changes: 10 additions & 2 deletions test/cli/log_get_level_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,20 @@ func TestLogGetLevel(t *testing.T) {
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)

assert.Greater(t, len(lines), 10)
// Should show all subsystems plus the global '*' level
assert.GreaterOrEqual(t, len(lines), expectedSubsystems)
Comment thread
lidel marked this conversation as resolved.
Outdated

// Check that each line has the format "subsystem: level"
for _, line := range lines {
Expand Down Expand Up @@ -85,6 +91,7 @@ func TestLogGetLevel(t *testing.T) {
})

t.Run("get-level with '*' returns global level", func(t *testing.T) {
t.Parallel()
node := harness.NewT(t).NewNode().Init().StartDaemon()
defer node.StopDaemon()

Expand All @@ -105,7 +112,7 @@ func TestLogGetLevel(t *testing.T) {
assert.Equal(t, "dpanic", parts[1])
})

t.Run("get-level reflects environment variable changes", func(t *testing.T) {
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()
Expand Down Expand Up @@ -135,4 +142,5 @@ func TestLogGetLevel(t *testing.T) {
assert.Error(t, res.Err)
assert.NotEqual(t, 0, len(res.Stderr.Lines()))
})

}