-
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
feat: add component logger #2198
Merged
Merged
Conversation
This file contains 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
maschad
requested changes
Nov 6, 2023
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.
very useful feature, great work. I left some comments and suggestions.
achingbrain
force-pushed
the
feat/add-peer-logger
branch
from
November 6, 2023 18:54
3b5c251
to
b1986b8
Compare
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
achingbrain
force-pushed
the
feat/add-peer-logger
branch
from
November 6, 2023 18:55
b1986b8
to
bf3bc2c
Compare
maschad
approved these changes
Nov 6, 2023
maschad
pushed a commit
to maschad/js-libp2p
that referenced
this pull request
Nov 10, 2023
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
3 tasks
achingbrain
added a commit
to ChainSafe/js-libp2p-yamux
that referenced
this pull request
Nov 26, 2023
Refactors code to use the component logger from libp2p to allow more flexible logging patterns. Refs: https://github.com/libp2p/js-libp2p/issue/2105 Refs: libp2p/js-libp2p#2198 Refs: https://github.com/libp2p/js-libp2p/issue/378
achingbrain
added a commit
to ChainSafe/js-libp2p-yamux
that referenced
this pull request
Nov 26, 2023
Refactors code to use the component logger from libp2p to allow more flexible logging patterns. Refs: https://github.com/libp2p/js-libp2p/issue/2105 Refs: libp2p/js-libp2p#2198 Refs: https://github.com/libp2p/js-libp2p/issue/378
achingbrain
added a commit
to achingbrain/js-libp2p-noise
that referenced
this pull request
Nov 26, 2023
Refactors code to use the component logger from libp2p to allow more flexible logging patterns. Nb. adds a `NoiseComponents` interface separate from `NoiseInit` that contains the `Metrics` instance - this is consistent with every other libp2p module. Refs: https://github.com/libp2p/js-libp2p/issue/2105 Refs: libp2p/js-libp2p#2198 Refs: https://github.com/libp2p/js-libp2p/issue/378
achingbrain
added a commit
to achingbrain/js-libp2p-noise
that referenced
this pull request
Nov 29, 2023
Refactors code to use the component logger from libp2p to allow more flexible logging patterns. Nb. adds a `NoiseComponents` interface separate from `NoiseInit` that contains the `Metrics` instance - this is consistent with every other libp2p module. Refs: https://github.com/libp2p/js-libp2p/issue/2105 Refs: libp2p/js-libp2p#2198 Refs: https://github.com/libp2p/js-libp2p/issue/378
achingbrain
added a commit
to achingbrain/js-libp2p-noise
that referenced
this pull request
Nov 29, 2023
Refactors code to use the component logger from libp2p to allow more flexible logging patterns. Nb. adds a `NoiseComponents` interface separate from `NoiseInit` that contains the `Metrics` instance - this is consistent with every other libp2p module. Refs: https://github.com/libp2p/js-libp2p/issue/2105 Refs: libp2p/js-libp2p#2198 Refs: https://github.com/libp2p/js-libp2p/issue/378
wemeetagain
added a commit
to ChainSafe/js-libp2p-noise
that referenced
this pull request
Nov 29, 2023
* fix: yield uint8arraylists instead of concatenating buffers In order to avoid unnecessary buffer copies, update to the new libp2p connection encrypter API that lets connection encrypters consume/yield lists of buffers instead of requiring them to be concatenated before/after encryption/decryption. * chore: fix tcp version * feat: use libp2p component logger Refactors code to use the component logger from libp2p to allow more flexible logging patterns. Nb. adds a `NoiseComponents` interface separate from `NoiseInit` that contains the `Metrics` instance - this is consistent with every other libp2p module. Refs: https://github.com/libp2p/js-libp2p/issue/2105 Refs: libp2p/js-libp2p#2198 Refs: https://github.com/libp2p/js-libp2p/issue/378 * chore: fix linter errors --------- Co-authored-by: Cayman <caymannava@gmail.com>
This was referenced Jan 18, 2024
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.
When running multiple libp2p instances simultaneously it's often hard to work out which log messages come from which instance. This PR solves the problem.
ComponentLogger
interface to libp2p which is an object that lets a component get a logger specific to that component.logger
config key to libp2p which is an implementation ofComponentLogger
.ComponentLogger
defaultLogger
- this preserves existing logging behaviourpeerLogger
- this prefixes all log lines with a truncated peer idprefixLogger
- this prefixes all log lines with an arbitrary stringlibp2p
uses the passed logger if one is configured, otherwise it usesdefaultLogger
to make this change backwards compatible.The logger is added to the
components
map so libp2p components can accept it as part of their required components and use theforComponent
function to create a component-specific logger.It will take a bit of time to thread the use of
ComponentLogger
throughout the monorepo, but this can be done in follow-up PRs since the existing logging behaviour is maintained by the changes here.For v1.x we may switch to
peerLogger
.Refs #2105
Change checklist