mirror of
https://github.com/hotomoe/hotomoe
synced 2024-12-12 05:38:12 +09:00
fix(backend/logger): context
の引数を渡すとloggerに設定されたcontextが上書きされてしまう問題を修正 (MisskeyIO#459)
This commit is contained in:
parent
2573df5c84
commit
8325431d4e
@ -13,6 +13,7 @@ import type { KEYWORD } from 'color-convert/conversions.js';
|
||||
export default class Logger {
|
||||
private readonly domain: string;
|
||||
private logger: pino.Logger;
|
||||
private context: Record<string, any> = {};
|
||||
|
||||
constructor(domain: string, _color?: KEYWORD, _store = true, parentLogger?: Logger) {
|
||||
if (parentLogger) {
|
||||
@ -34,7 +35,7 @@ export default class Logger {
|
||||
formatters: {
|
||||
level: (label, number) => ({ severity: label, level: number }),
|
||||
},
|
||||
mixin: () => ({ cluster: cluster.isPrimary ? 'primary' : `worker#${cluster.worker!.id}` }),
|
||||
mixin: () => ({ cluster: cluster.isPrimary ? 'primary' : `worker#${cluster.worker!.id}`, ...this.context }),
|
||||
transport: !envOption.logJson ? {
|
||||
target: 'pino-pretty',
|
||||
options: {
|
||||
@ -57,7 +58,7 @@ export default class Logger {
|
||||
|
||||
@bindThis
|
||||
public setContext(context: Record<string, any>): void {
|
||||
this.logger = this.logger.child({ context });
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@bindThis
|
||||
|
Loading…
Reference in New Issue
Block a user