feat(logging): JSON形式の構造化ログでログを出力できるように (MisskeyIO#346)
This commit is contained in:
@@ -41,7 +41,7 @@ export default class Logger {
|
||||
|
||||
@bindThis
|
||||
private log(level: Level, message: string, data?: Record<string, any> | null, important = false, subContexts: Context[] = [], store = true): void {
|
||||
if (envOption.quiet) return;
|
||||
if (envOption.quiet && !envOption.logJson) return;
|
||||
if (!this.store) store = false;
|
||||
if (level === 'debug') store = false;
|
||||
|
||||
@@ -50,6 +50,19 @@ export default class Logger {
|
||||
return;
|
||||
}
|
||||
|
||||
if (envOption.logJson) {
|
||||
console.log(JSON.stringify({
|
||||
time: new Date().toISOString(),
|
||||
level: level,
|
||||
message: message,
|
||||
data: data,
|
||||
important: important,
|
||||
context: [this.context].concat(subContexts).join('.'),
|
||||
cluster: cluster.isPrimary ? 'primary' : `worker-${cluster.worker!.id}`,
|
||||
}));
|
||||
return;
|
||||
}
|
||||
|
||||
const time = dateFormat(new Date(), 'HH:mm:ss');
|
||||
const worker = cluster.isPrimary ? '*' : cluster.worker!.id;
|
||||
const l =
|
||||
|
Reference in New Issue
Block a user