refactor(backend): remove unused logger option

This commit is contained in:
syuilo 2024-06-06 10:01:50 +09:00
parent d4a8c63264
commit dbf9e1194b
5 changed files with 10 additions and 14 deletions

View File

@ -15,7 +15,7 @@ export class LoggerService {
} }
@bindThis @bindThis
public getLogger(domain: string, color?: KEYWORD | undefined, store?: boolean) { public getLogger(domain: string, color?: KEYWORD | undefined) {
return new Logger(domain, color, store); return new Logger(domain, color);
} }
} }

View File

@ -14,6 +14,6 @@ export class ChartLoggerService {
constructor( constructor(
private loggerService: LoggerService, private loggerService: LoggerService,
) { ) {
this.logger = this.loggerService.getLogger('chart', 'white', process.env.NODE_ENV !== 'test'); this.logger = this.loggerService.getLogger('chart', 'white');
} }
} }

View File

@ -22,31 +22,27 @@ type Level = 'error' | 'success' | 'warning' | 'debug' | 'info';
export default class Logger { export default class Logger {
private context: Context; private context: Context;
private parentLogger: Logger | null = null; private parentLogger: Logger | null = null;
private store: boolean;
constructor(context: string, color?: KEYWORD, store = true) { constructor(context: string, color?: KEYWORD) {
this.context = { this.context = {
name: context, name: context,
color: color, color: color,
}; };
this.store = store;
} }
@bindThis @bindThis
public createSubLogger(context: string, color?: KEYWORD, store = true): Logger { public createSubLogger(context: string, color?: KEYWORD): Logger {
const logger = new Logger(context, color, store); const logger = new Logger(context, color);
logger.parentLogger = this; logger.parentLogger = this;
return logger; return logger;
} }
@bindThis @bindThis
private log(level: Level, message: string, data?: Record<string, any> | null, important = false, subContexts: Context[] = [], store = true): void { private log(level: Level, message: string, data?: Record<string, any> | null, important = false, subContexts: Context[] = []): void {
if (envOption.quiet) return; if (envOption.quiet) return;
if (!this.store) store = false;
if (level === 'debug') store = false;
if (this.parentLogger) { if (this.parentLogger) {
this.parentLogger.log(level, message, data, important, [this.context].concat(subContexts), store); this.parentLogger.log(level, message, data, important, [this.context].concat(subContexts));
return; return;
} }

View File

@ -53,7 +53,7 @@ export class FileServerService {
private internalStorageService: InternalStorageService, private internalStorageService: InternalStorageService,
private loggerService: LoggerService, private loggerService: LoggerService,
) { ) {
this.logger = this.loggerService.getLogger('server', 'gray', false); this.logger = this.loggerService.getLogger('server', 'gray');
//this.createServer = this.createServer.bind(this); //this.createServer = this.createServer.bind(this);
} }

View File

@ -68,7 +68,7 @@ export class ServerService implements OnApplicationShutdown {
private loggerService: LoggerService, private loggerService: LoggerService,
private oauth2ProviderService: OAuth2ProviderService, private oauth2ProviderService: OAuth2ProviderService,
) { ) {
this.logger = this.loggerService.getLogger('server', 'gray', false); this.logger = this.loggerService.getLogger('server', 'gray');
} }
@bindThis @bindThis