-
-
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
Conversation
Answering some questions:
I think this is fine if you had no daemon? This is consistent with the
You mean adjusting Text version (not JSON)? Yes, I think for Text output skipping level name (when provided explicitly) makes sense. |
go get github.com/ipfs/go-log/v2@1d9b5d3dc8e2 && make mod_tidy
f658f9b
to
5b2597f
Compare
This comment was marked as resolved.
This comment was marked as resolved.
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.
@gammazero I would also prefer to have a single command that does both get and set, but it gets hairy due to mixing global level, "all", and subsystem names. The core issue is that "all" is used as a special keyword to represent all subsystems, but it could theoretically conflict with an actual subsystem named "all" (code has this TODO comment about this). Currently, when users specify NAMING TBD (unsure as non-native speaker) I think the Something like: Get Operations (1 arg or no args)# Get all subsystem levels including default
ipfs log level
# Output:
# default: error
# autonat: error
# dht: error
# bitswap: warn
# ...
# Get global default level only
ipfs log level default
# Output: error
# Get specific subsystem level
ipfs log level dht
# Output: error
# Get wildcard (same as default)
ipfs log level '*'
# Output: error
# Edge case: subsystem actually named "default"
ipfs log level default
# Output: error (ambiguous - shows global default, not subsystem) Set Operations (2 args)# Set global default level
ipfs log level default debug
# Changes: * → debug
# Set using wildcard directly
ipfs log level '*' debug
# Changes: * → debug
# Set specific subsystem level
ipfs log level dht info
# Changes: dht → info
# Set multiple levels (3+ args)
ipfs log level default debug dht info bitswap warn
# Changes: * → debug, dht → info, bitswap → warn OR.. an alternative is to add Thoughts? @gammazero @SgtPooki |
Colo notes:
|
@lidel @SgtPooki The use of "*" and "all" in your examples appear identical. If that is the case, then should one of those be dropped? I updated the PR so that, when getting levels, specifying the subsystem "default" returns only the current default log level. When getting log levels for all subsystems, the default level is identified by the key "default". The behavior IMO should be: Examples getting log level:
Examples setting 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.
@lidel Thank you for these changes. Very nice finishing touch.
during testing having to quore/escape '*' was really annoying plus removing it is a breaking change restored it and added tests that ensure it works the same way as '*'
@gammazero pushed one more: during testing having to quote/escape '*' in terminal feels really annoying 😅 plus removing it is was a breaking change. I've restored |
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.
Lgtm, added some examples to ipfs log level --help
to cover all cases and then generated tests for those cases.
@SgtPooki mind taking a look last time if this final version does all you need?
Getting Log Levels
# Show only the default fallback level
$ curl -X POST "http://127.0.0.1:5001/api/v0/log/level"
{"Levels":{"":"error"}}
# Show all subsystem levels (100+ lines)
$ curl -X POST "http://127.0.0.1:5001/api/v0/log/level?arg=all"
{"Levels":{"(default)":"error","autonat":"error","autonatv2":"error","autorelay":"error","autotls":"error","badger":"error","basichost":"error","bitswap":"error","bitswap/bsnet":"error","bitswap/client":"error","bitswap/client/getter":"error","bitswap/client/msgq":"error","bitswap/client/peermgr":"error","bitswap/client/sesspeermgr":"error","bitswap/connevtman":"error","bitswap/server":"error","bitswap/server/decision":"error","bitswap/session":"error","blankhost":"error","blockservice":"error","blockstore":"error","bootstrap":"error","boxo/gateway":"error","canonical-log":"error","chunk":"error","cmd/ipfs":"error","cmds":"error","cmds/cli":"error","cmds/files":"error","cmds/http":"error","command":"error","connmgr":"error","core":"error","core/commands":"error","core/commands/cmdenv":"error","core/commands/ipns":"error","core/server":"error","core:constructor":"error","corerepo":"error","coreunix":"error","dht":"error","dht-crawler":"error","dht.pb":"error","dht/RtDiversityFilter":"error","dht/RtRefreshManager":"error","dht/netsize":"error","discovery-backoff":"error","diversityFilter":"error","doh":"error","eventbus":"error","filestore":"error","flatfs":"error","fsrepo":"error","fullrtdht":"error","fuse/ipfs":"error","fuse/ipns":"error","fxtestplugin":"error","gc":"error","http-peer-id-auth":"error","httpnet":"error","internal/nat":"error","ipns":"error","ipns/repub":"error","keystore":"error","libp2phttp":"error","lock":"error","mdns":"error","merkledag":"error","metrics-prometheus":"error","mfs":"error","mount":"error","namesys":"error","nat":"error","net/identify":"error","node":"error","nopfs":"error","nopfs-blocks":"error","p2p-circuit":"error","p2p-config":"error","p2p-holepunch":"error","p2p-mount":"error","p2pnode":"error","path/resolver":"error","pebble":"error","peering":"error","peerstore":"error","pin":"error","ping":"error","pinning-service-http-client":"error","plugin/loader":"error","plugin/peerlog":"error","profile":"error","provider":"error","providers":"error","pstoremanager":"error","pubsub":"error","pubsub-valuestore":"error","quic-transport":"error","quic-utils":"error","rcmgr":"error","relay":"error","remotepinning/mfs":"error","resourcemanager":"error","reuseport-transport":"error","routedhost":"error","routing/composable":"error","routing/delegated":"error","routing/http/client":"error","routing/http/contentrouter":"error","routing/http/filters":"error","routing/http/server":"error","routing/provqrymgr":"error","socket-activation":"error","swarm2":"error","table":"error","tcp-demultiplex":"error","tcp-tpt":"error","ulimit":"error","unixfs":"error","unixfs-hamt":"error","upgrader":"error","webrtc-transport":"error","webrtc-transport-pion":"error","webrtc-udpmux":"error","websocket-transport":"error","webtransport":"error"}}
# Show level for 'core' subsystem only
$ curl -X POST "http://127.0.0.1:5001/api/v0/log/level?arg=core"
{"Levels":{"core":"error"}}
Setting Log Levels
# Set 'core' to 'debug' (default unchanged)
$ curl -X POST "http://127.0.0.1:5001/api/v0/log/level?arg=core&arg=debug"
{"Message":"Changed log level of 'core' to 'debug'\n"}
# Set ALL to 'info' (including default)
$ curl -X POST "http://127.0.0.1:5001/api/v0/log/level?arg=all&arg=info"
{"Message":"Changed log level of '*' to 'info'\n"}
# Reset 'core' to use current default level
$ curl -X POST "http://127.0.0.1:5001/api/v0/log/level?arg=core&arg=default"
{"Message":"Changed log level of 'core' to 'error'\n"}
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.
I had removed all
, but I like this better to avoid shell escaping
@SgtPooki Please take a look before merge, since you are primary consumer of the log level getters. |
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.
lgtm. this should work for the webui diagnostics screen. thanks!
@ipfs/kubo-maintainers fysa |
Modifies the
/api/v0/log/level
endpoint to query current logging levels when a new level is not specified.This depends on
github.com/ipfs/go-log
v2.8.0Related ipfs/ipfs-webui#1925
Closes #10882
Updated command arguments
Examples getting log level:
ipfs log level
→ Show default level onlyipfs log level '*'
→ Show log level for every subsystem, including default levelipfs log level foo
→ Show log level for "foo" subsystem onlyExamples setting log level:
ipfs log level '*' debug
→ Set all subsystems and default to "debug" levelipfs log level '*' default
→ Set all subsystems to current default levelipfs log level foo debug
→ Set level of "foo" subsystem to "debug"ipfs log level foo default
→ Set level of "foo" subsystem to current default levelExample updated command use
On Command Line
Get default log level
> ipfs log level error
Get all log levels
Get log level for a specific subsystem
> ipfs log level autonatv2 autonatv2: error
Set log level for a specific subsystem
Set log level for all subsystems including default
Using HTTP endpoint
Get default log level
Get all log levels with HTTP endpoint
Get log level for a specific subsystem
Set log level for a specific subsystem
Set log level for all subsystems including default