fatsify核心功能示例测试!!!
This commit is contained in:
43
node_modules/pino/examples/basic.js
generated
vendored
Normal file
43
node_modules/pino/examples/basic.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
'use strict'
|
||||
|
||||
// Pino's primary usage writes ndjson to `stdout`:
|
||||
const pino = require('..')()
|
||||
|
||||
// However, if "human readable" output is desired,
|
||||
// `pino-pretty` can be provided as the destination
|
||||
// stream by uncommenting the following line in place
|
||||
// of the previous declaration:
|
||||
// const pino = require('..')(require('pino-pretty')())
|
||||
|
||||
pino.info('hello world')
|
||||
pino.error('this is at error level')
|
||||
pino.info('the answer is %d', 42)
|
||||
pino.info({ obj: 42 }, 'hello world')
|
||||
pino.info({ obj: 42, b: 2 }, 'hello world')
|
||||
pino.info({ nested: { obj: 42 } }, 'nested')
|
||||
setImmediate(() => {
|
||||
pino.info('after setImmediate')
|
||||
})
|
||||
pino.error(new Error('an error'))
|
||||
|
||||
const child = pino.child({ a: 'property' })
|
||||
child.info('hello child!')
|
||||
|
||||
const childsChild = child.child({ another: 'property' })
|
||||
childsChild.info('hello baby..')
|
||||
|
||||
pino.debug('this should be mute')
|
||||
|
||||
pino.level = 'trace'
|
||||
|
||||
pino.debug('this is a debug statement')
|
||||
|
||||
pino.child({ another: 'property' }).debug('this is a debug statement via child')
|
||||
pino.trace('this is a trace statement')
|
||||
|
||||
pino.debug('this is a "debug" statement with "')
|
||||
|
||||
pino.info(new Error('kaboom'))
|
||||
pino.info(null)
|
||||
|
||||
pino.info(new Error('kaboom'), 'with', 'a', 'message')
|
||||
68
node_modules/pino/examples/transport.js
generated
vendored
Normal file
68
node_modules/pino/examples/transport.js
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
'use strict'
|
||||
|
||||
const pino = require('..')
|
||||
const { tmpdir } = require('node:os')
|
||||
const { join } = require('node:path')
|
||||
|
||||
const file = join(tmpdir(), `pino-${process.pid}-example`)
|
||||
|
||||
const transport = pino.transport({
|
||||
targets: [{
|
||||
level: 'warn',
|
||||
target: 'pino/file',
|
||||
options: {
|
||||
destination: file
|
||||
}
|
||||
/*
|
||||
}, {
|
||||
level: 'info',
|
||||
target: 'pino-elasticsearch',
|
||||
options: {
|
||||
node: 'http://localhost:9200'
|
||||
}
|
||||
*/
|
||||
}, {
|
||||
level: 'info',
|
||||
target: 'pino-pretty'
|
||||
}]
|
||||
})
|
||||
|
||||
const logger = pino(transport)
|
||||
|
||||
logger.info({
|
||||
file
|
||||
}, 'logging destination')
|
||||
|
||||
logger.info('hello world')
|
||||
logger.error('this is at error level')
|
||||
logger.info('the answer is %d', 42)
|
||||
logger.info({ obj: 42 }, 'hello world')
|
||||
logger.info({ obj: 42, b: 2 }, 'hello world')
|
||||
logger.info({ nested: { obj: 42 } }, 'nested')
|
||||
logger.warn('WARNING!')
|
||||
setImmediate(() => {
|
||||
logger.info('after setImmediate')
|
||||
})
|
||||
logger.error(new Error('an error'))
|
||||
|
||||
const child = logger.child({ a: 'property' })
|
||||
child.info('hello child!')
|
||||
|
||||
const childsChild = child.child({ another: 'property' })
|
||||
childsChild.info('hello baby..')
|
||||
|
||||
logger.debug('this should be mute')
|
||||
|
||||
logger.level = 'trace'
|
||||
|
||||
logger.debug('this is a debug statement')
|
||||
|
||||
logger.child({ another: 'property' }).debug('this is a debug statement via child')
|
||||
logger.trace('this is a trace statement')
|
||||
|
||||
logger.debug('this is a "debug" statement with "')
|
||||
|
||||
logger.info(new Error('kaboom'))
|
||||
logger.info(null)
|
||||
|
||||
logger.info(new Error('kaboom'), 'with', 'a', 'message')
|
||||
Reference in New Issue
Block a user