Skip to content
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: use peer logger by default #2257

Closed
wants to merge 1 commit into from
Closed

Conversation

achingbrain
Copy link
Member

@achingbrain achingbrain commented Nov 26, 2023

Switches the default logger to one that prefixes log lines with a truncated version of the node's peer id.

This can be overridden at configuration time, eg:

const node = await createLibp2p()

// e.g.
// 12…tsSg:libp2p:component hello world
import { defaultLogger } from '@libp2p/logger'

const node = await createLibp2p({
  logger: defaultLogger()
})

// e.g.
// libp2p:component hello world
import { prefixLogger } from '@libp2p/logger'

const node = await createLibp2p({
  logger: prefixLogger('custom-prefix')
})

// e.g.
// custom-prefix:libp2p:component hello world

Refs: #2105
Refs: #2198
Refs: #378

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if necessary (this includes comments as well)
  • I have added tests that prove my fix is effective or that my feature works

Switches the default logger to one that prefixes log lines with a
truncated version of the node's peer id.
@achingbrain achingbrain requested a review from a team as a code owner November 26, 2023 08:09
@achingbrain
Copy link
Member Author

Do we want this? I know we said we did, it makes life easier when you have two nodes running in the same process but it’s not really a real-world setup.

@wemeetagain
Copy link
Member

I think it would be more useful to just enable this in tests, and otherwise use the default logger

@wemeetagain
Copy link
Member

Its also may be a problem that no longer exists now that the logger is centrally configured and passed thru all the components.

@achingbrain
Copy link
Member Author

Going to close this, it's easy enough to configure if the user wants it.

@achingbrain achingbrain deleted the feat/use-peer-logger branch November 27, 2023 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants