mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-27 22:39:33 +09:00
fix(logging): pino-prettyの使用時のメモリ使用量の問題を修正 (MisskeyIO#506)
This commit is contained in:
parent
1c3742b711
commit
8169fe4e73
@ -5,10 +5,22 @@
|
|||||||
|
|
||||||
import cluster from 'node:cluster';
|
import cluster from 'node:cluster';
|
||||||
import { pino } from 'pino';
|
import { pino } from 'pino';
|
||||||
|
import pinoPretty from 'pino-pretty';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import { envOption } from './env.js';
|
import { envOption } from './env.js';
|
||||||
import type { KEYWORD } from 'color-convert/conversions.js';
|
import type { KEYWORD } from 'color-convert/conversions.js';
|
||||||
|
|
||||||
|
// @ts-expect-error it gives error if we use pinoPretty.PinoPretty instead of pinoPretty.
|
||||||
|
const pinoPrettyStream = pinoPretty({
|
||||||
|
levelFirst: false,
|
||||||
|
levelKey: 'level',
|
||||||
|
timestampKey: 'time',
|
||||||
|
messageKey: 'message',
|
||||||
|
errorLikeObjectKeys: ['e', 'err', 'error'],
|
||||||
|
ignore: 'severity,pid,hostname,cluster,important',
|
||||||
|
messageFormat: '@{cluster} | {message}',
|
||||||
|
});
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default class Logger {
|
export default class Logger {
|
||||||
private readonly domain: string;
|
private readonly domain: string;
|
||||||
@ -36,19 +48,7 @@ export default class Logger {
|
|||||||
level: (label, number) => ({ severity: label, level: number }),
|
level: (label, number) => ({ severity: label, level: number }),
|
||||||
},
|
},
|
||||||
mixin: () => ({ cluster: cluster.isPrimary ? 'primary' : `worker#${cluster.worker!.id}`, ...this.context }),
|
mixin: () => ({ cluster: cluster.isPrimary ? 'primary' : `worker#${cluster.worker!.id}`, ...this.context }),
|
||||||
transport: !envOption.logJson ? {
|
}, !envOption.logJson ? pinoPrettyStream : undefined);
|
||||||
target: 'pino-pretty',
|
|
||||||
options: {
|
|
||||||
levelFirst: false,
|
|
||||||
levelKey: 'level',
|
|
||||||
timestampKey: 'time',
|
|
||||||
messageKey: 'message',
|
|
||||||
errorLikeObjectKeys: ['e', 'err', 'error'],
|
|
||||||
ignore: 'severity,pid,hostname,cluster,important',
|
|
||||||
messageFormat: '@{cluster} | {message}',
|
|
||||||
},
|
|
||||||
} : undefined,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
|
Loading…
Reference in New Issue
Block a user