forked from ekino/node-logger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasic.js
47 lines (42 loc) · 1.36 KB
/
basic.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
#!/usr/bin/env node
import { createBenchmarkSuite, initializeLoggers, runSuiteWithDynamicTimeout } from './utils.js'
const { ekinoLoggerV2, ekinoLoggerV3, pinoLogger, winstonLogger } = initializeLoggers()
const suite = createBenchmarkSuite('Logger Benchmark - Basic')
const logObject = {
user: 'John Doe',
action: 'Test Action',
timestamp: new Date(),
details: {
ipAddress: '192.168.1.1',
location: 'New York',
permissions: ['read', 'write', 'admin'],
metadata: { session: 'abcdef12345', retries: 2 },
},
}
const contextId = 'a037df3b-dbee-448e-9abb-8024d867ccc8'
suite
.addTest('@ekino/logger v2.x', () => {
ekinoLoggerV2.info(
contextId,
'This is a benchmark log message for @ekino/logger v2.x',
logObject
)
})
.addTest('@ekino/logger v3.x', () => {
ekinoLoggerV3.info(
contextId,
'This is a benchmark log message for @ekino/logger v3.x',
logObject
)
})
.addTest('Winston', () => {
winstonLogger.info('This is a benchmark log message for Winston', logObject)
})
.addTest('Pino', () => {
pinoLogger.info({
ctxId: contextId,
...logObject,
message: 'This is a benchmark log message for Pino',
})
})
await runSuiteWithDynamicTimeout(suite)