@@ -9,6 +9,7 @@ import { base58btc } from 'multiformats/bases/base58'
9
9
import { base32 } from 'multiformats/bases/base32'
10
10
import { base64 } from 'multiformats/bases/base64'
11
11
import { Key } from 'interface-datastore'
12
+ import sinon from 'sinon'
12
13
13
14
describe ( 'logger' , ( ) => {
14
15
it ( 'creates a logger' , ( ) => {
@@ -70,13 +71,26 @@ describe('logger', () => {
70
71
expect ( debug . formatters ) . to . have . property ( 'p' ) . that . is . a ( 'function' )
71
72
expect ( debug . formatters ) . to . have . property ( 'c' ) . that . is . a ( 'function' )
72
73
expect ( debug . formatters ) . to . have . property ( 'k' ) . that . is . a ( 'function' )
73
- expect ( debug . formatters ) . to . have . property ( 'ma' ) . that . is . a ( 'function' )
74
+ expect ( debug . formatters ) . to . have . property ( 'a' ) . that . is . a ( 'function' )
75
+ } )
76
+
77
+ it ( 'test printf style formatting' , ( ) => {
78
+ const log = logger ( 'printf-style' )
79
+ debug . enable ( 'printf-style' )
80
+
81
+ const ma = multiaddr ( '/ip4/127.0.0.1/tcp/4001' )
82
+
83
+ const debugSpy = sinon . spy ( debug , 'log' )
84
+
85
+ log ( 'multiaddr %a' , ma )
86
+
87
+ expect ( debugSpy . firstCall . args [ 0 ] , 'Multiaddr formatting not included' ) . to . include ( `multiaddr ${ ma . toString ( ) } ` )
74
88
} )
75
89
76
90
it ( 'test ma formatter' , ( ) => {
77
91
const ma = multiaddr ( '/ip4/127.0.0.1/tcp/4001' )
78
92
79
- expect ( debug . formatters . ma ( ma ) ) . to . equal ( ma . toString ( ) )
93
+ expect ( debug . formatters . a ( ma ) ) . to . equal ( ma . toString ( ) )
80
94
} )
81
95
82
96
it ( 'test peerId formatter' , ( ) => {
0 commit comments