-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
56 lines (50 loc) · 1.75 KB
/
test.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
const path = require('path')
const { LogLevel, Log, ObjectSerializationStrategy, Formatters, LogWriter } = require(".")
const IS_DEV = process.env.NODE_ENV !== 'production'
const ROOT = path.resolve(__dirname)
Log.init({
global: {
inspectionColor: true,
assertionLevel: LogLevel.ERROR,
assertionsEnabled: true,
},
providers: {
globalLoggers: {
development: () => ({
enabled: IS_DEV,
level: LogLevel.DEBUG,
serializationStrategy: ObjectSerializationStrategy.INSPECT,
writers: [
LogWriter.stdout({ level: LogLevel.ERROR | LogLevel.WARN }),
LogWriter.file(`${ROOT}/logs/global-json.log`, { formatter: Formatters.jsonFormatter })
]
})
},
featureLogger: () => ({
//enabled: false,
//level: LogLevel.DEBUG,
serializationStrategy: ObjectSerializationStrategy.INSPECT,
writers: [
LogWriter.stdout(),
LogWriter.file(`${ROOT}/logs/named-monochrome.log`, { formatter: Formatters.monochromeFormatter, level: LogLevel.WARN }),
LogWriter.file(`${ROOT}/logs/named-json.log`, { formatter: Formatters.jsonFormatter, level: LogLevel.ERROR })
]
})
}
})
// Log.debug('Debugging...')
// Log.debug([1, 2, 3])
// Log.info('Testing %s', 123)
// Log.warn({ stuff: [3, 4] })
// Log.error('Testing Info %s', { value: true, other: 'things' })
// const [a, b] = [1, 0]
// Log.assert(a === b, '%d should equal %d', a, b)
// const [c, d] = [1, 1]
// Log.assert(c === d, '%d should equal %d', c, d)
const featureLogger = Log.forFeature('Test')
featureLogger.debug('Debug')
featureLogger.info('Info')
featureLogger.warn('Warning')
featureLogger.error('Error')
featureLogger.fatal('Fatal error')
featureLogger.assert(1 == 0, '%d should equal %d', 1, 0)