-
Notifications
You must be signed in to change notification settings - Fork 4
/
levels.js
37 lines (27 loc) · 1.09 KB
/
levels.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import debugF from 'debug'
import Log from '../src/index.js'
Log.options({ level: 'trace' }) // call options before your instances
const log = new Log('test')
log.trace({ trace: 'it' }) // logs an object at level TRACE
log.debug({ object: 1 }) // logs an object at level DEBUG
log.info('%s world', 'hello') // logs a formatted string at level INFO
log.warn('huh %o', { ghost: 'rider' }) // logs a formatted object at level WARN
log.error(new Error('boom')) // logs an Error at level ERROR
log.fatal('fatal test') // logs an Error at level FATAL
log.log('always logs') // always logs regardless of set level
const logA = new Log('log:A')
logA.debug({ object: 1 })
logA.info('%s world', 'hello')
logA.warn('huh %o', { ghost: 'rider' })
logA.error(new Error('baam'))
logA.fatal('fatal A')
const logB = new Log('log:B')
logB.debug({ object: 1 })
logB.info('%s world', 'hello')
logB.warn('huh %o', { ghost: 'rider' })
logB.error(new Error('bbbm'))
logB.fatal('fatal B')
const debug = debugF('using-debug')
debug('using %s', 'debug')
const debugA = debugF('using-debug:A')
debugA('using %s', 'debug - feature A')