enhance(logging): ログの処理をpinoに置き換える (MisskeyIO#364)

This commit is contained in:
まっちゃとーにゅ
2024-01-16 22:13:35 +09:00
committed by tamaina
parent 670d509696
commit a7e3f6c1a9
4 changed files with 157 additions and 146 deletions

View File

@@ -80,8 +80,9 @@ import { MiBubbleGameRecord } from '@/models/BubbleGameRecord.js';
import { MiReversiGame } from '@/models/ReversiGame.js';
import { Config } from '@/config.js';
import MisskeyLogger from '@/logger.js';
import { bindThis } from '@/decorators.js';
import { envOption } from './env.js';
import MisskeyLogger from '@/logger.js';
export const dbLogger = new MisskeyLogger('db');
@@ -90,6 +91,8 @@ const sqlLogger = dbLogger.createSubLogger('sql', 'gray', false);
class MyCustomLogger implements Logger {
@bindThis
private highlight(sql: string) {
if (envOption.logJson) return sql;
return highlight.highlight(sql, {
language: 'sql', ignoreIllegals: true,
});
@@ -97,7 +100,7 @@ class MyCustomLogger implements Logger {
@bindThis
public logQuery(query: string, parameters?: any[]) {
sqlLogger.info(this.highlight(query).substring(0, 100));
sqlLogger.info(this.highlight(query));
}
@bindThis