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
public getLogger(domain: string, color?: KEYWORD | undefined, store?: boolean) {
return new Logger(domain, color, store);
public getLogger(domain: string, color?: KEYWORD | undefined) {
return new Logger(domain, color);
}
}

View File

@ -14,6 +14,6 @@ export class ChartLoggerService {
constructor(
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 {
private context: Context;
private parentLogger: Logger | null = null;
private store: boolean;
constructor(context: string, color?: KEYWORD, store = true) {
constructor(context: string, color?: KEYWORD) {
this.context = {
name: context,
color: color,
};
this.store = store;
}
@bindThis
public createSubLogger(context: string, color?: KEYWORD, store = true): Logger {
const logger = new Logger(context, color, store);
public createSubLogger(context: string, color?: KEYWORD): Logger {
const logger = new Logger(context, color);
logger.parentLogger = this;
return logger;
}
@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 (!this.store) store = false;
if (level === 'debug') store = false;
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;
}

View File

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

View File

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