mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 16:03:21 +00:00
32 lines
596 B
JavaScript
32 lines
596 B
JavaScript
const pino = require('pino');
|
|
|
|
const PinoLevelToSeverityLookup = {
|
|
trace: 'DEBUG',
|
|
debug: 'DEBUG',
|
|
info: 'INFO',
|
|
warn: 'WARNING',
|
|
error: 'ERROR',
|
|
fatal: 'CRITICAL',
|
|
};
|
|
|
|
const logger = (defaultConfig) =>
|
|
pino({
|
|
...defaultConfig,
|
|
messageKey: 'message',
|
|
formatters: {
|
|
level(label, number) {
|
|
return {
|
|
severity:
|
|
PinoLevelToSeverityLookup[label] ||
|
|
PinoLevelToSeverityLookup['info'],
|
|
level: number,
|
|
};
|
|
},
|
|
},
|
|
mixin: () => ({ name: 'custom-pino-instance' }),
|
|
});
|
|
|
|
module.exports = {
|
|
logger,
|
|
};
|