Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Commit

Permalink
fix: log cids (#165)
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain authored Feb 11, 2022
1 parent f485b76 commit 68831e8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/libp2p-logger/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import debug from 'debug'
import { base58btc } from 'multiformats/bases/base58'
import { base32 } from 'multiformats/bases/base32'
import type { PeerId } from '@libp2p/interfaces/peer-id'
import type { CID } from 'multiformats/cid'

// Add a formatter for converting to a base58 string
debug.formatters.b = (v: Uint8Array) => {
Expand All @@ -18,6 +19,11 @@ debug.formatters.p = (p: PeerId) => {
return p.toString(base58btc)
}

// Add a formatter for stringifying CIDs
debug.formatters.c = (c: CID) => {
return c.toString()
}

export interface Logger {
(formatter: any, ...args: any[]): void
error: (formatter: any, ...args: any[]) => void
Expand Down

0 comments on commit 68831e8

Please sign in to comment.