• Create a component logger that will prefix any log messages with a truncated peer id.

    Parameters

    Returns ComponentLogger

    Example

    import { peerLogger } from '@libp2p/logger'
    import { peerIdFromString } from '@libp2p/peer-id'

    const peerId = peerIdFromString('12D3FooBar')
    const logger = peerLogger(peerId)

    const log = logger.forComponent('my-component')
    log.info('hello world')
    // logs "12…oBar:my-component hello world"