-
Notifications
You must be signed in to change notification settings - Fork 447
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
refactor: logging improvements - all components should receive a logger component #2105
Comments
Developer ergonomics should be considered. Given the logger
Logging is disabled by default: $ libp2p
* no output * Even when logging is enabled trace logging is still disabled by default: $ DEBUG=libp2p:* libp2p
libp2p:yamux hello
libp2p:yamux:error oh no an error
* no trace logging* Turning on trace logging: $ DEBUG=libp2p:*,*:trace libp2p
libp2p:yamux hello
libp2p:yamux:error oh no an error
libp2p:yamux:trace really detailed trace log Prefixing with the PeerId will result in:
Turning on logging might then be like: $ DEBUG=*:libp2p:* libp2p
123Foo:libp2p:yamux hello
123Foo:libp2p:yamux:error oh no an error Turning on trace logging is the same as before: $ DEBUG=*:libp2p:*,*:trace libp2p
123Foo:libp2p:yamux hello
123Foo:libp2p:yamux:error oh no an error
123Foo:libp2p:yamux:trace really detailed trace log |
I agree but are these examples to suggest that it would be too noisy? Because the current alternative to this is to have the peerID appended such as: $ DEBUG=*:libp2p:*,*:trace libp2p
libp2p:yamux hello by peer 123Foo3252352QwmsaIksFN...
libp2p:yamux:error oh no an error by peer 123Foo3252352QwmsaIksFN...
libp2p:yamux:trace really detailed trace log by peer 123Foo3252352QwmsaIksFN... I think having the characters prefixed is a good compromise, especially since the namespaces are distinguished by colour anyway. |
I feel like the exact text in #2105 (comment) needs to be moved to docs! |
If it's in the format Alex mentions above, it should be filterable (DX expectation), but it wouldn't be, as far as I know. Can we facilitate a user adding that functionality (prefix logs with peerIds) without defaulting to it? I don't think this is an everyday use case, but enabling support would help debugging. How do other networking tools handle an aggregate log with different peer sources? (I should look into wireshark or other examples.) |
It's more of a design decision conversation, I don't think we're going to refer back to this or direct new users to read it.
I don't think this is something we'd consider. One problem I see with:
is that all PeerIds are prefixed with the same few characters - Given the following range of peer IDs you might want the first two characters + the last, I don't know, four?
Or with a divider (not
|
I think this is the best suggestion. I am going to be a bit pedantic and suggest we use I also think using the first 3 and last 4 characters is the most viable right now, I say first 3 as it's a bit more obvious to distinguish between Ed25519 and secp256k1 peer ids. |
Well if we're going to be pedantic we should use the |
Great idea!! |
Adds a `peerLogger` to `@libp2p/logger` that prefixes all log messages with a truncated peer id. When running multiple libp2p instances simultaneously it's often hard to work out which log messages come from which instance. This will solve this problem. Refs #2105
Adds a `peerLogger` to `@libp2p/logger` that prefixes all log messages with a truncated peer id. When running multiple libp2p instances simultaneously it's often hard to work out which log messages come from which instance. This will solve this problem. Refs #2105
Adds a `ComponentLogger` to `@libp2p/logger` with implementations that prefixes all log messages with a truncated peer id or an arbitrary string. When running multiple libp2p instances simultaneously it's often hard to work out which log messages come from which instance. This will solve this problem. Refs #2105
Adds a `ComponentLogger` to `@libp2p/logger` with implementations that prefixes all log messages with a truncated peer id or an arbitrary string. When running multiple libp2p instances simultaneously it's often hard to work out which log messages come from which instance. This will solve this problem. Refs #2105
Adds a `ComponentLogger` to `@libp2p/logger` with implementations that prefixes all log messages with a truncated peer id or an arbitrary string. When running multiple libp2p instances simultaneously it's often hard to work out which log messages come from which instance. This will solve this problem. Refs libp2p#2105
Closed by #2228 |
We discussed in https://pl-strflt.notion.site/Mob-Coding-session-2f0cdd202cdf4b6faec03bd87ca15703?pvs=4 how having a logger component that includes the last 5 characters of the peerId could be incredibly useful when running multiple nodes locally
One way we discussed for accomplishing this is to pass a logger component to all components similar to how other components reference each other.
Tasks
The text was updated successfully, but these errors were encountered: