2023-07-27 05:31:52 +00:00
|
|
|
/*
|
2024-02-12 02:37:45 +00:00
|
|
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
2023-07-27 05:31:52 +00:00
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2022-12-10 06:45:30 +00:00
|
|
|
import { LoggerService } from '@nestjs/common';
|
|
|
|
import Logger from '@/logger.js';
|
|
|
|
|
|
|
|
const logger = new Logger('core', 'cyan');
|
|
|
|
const nestLogger = logger.createSubLogger('nest', 'green', false);
|
|
|
|
|
|
|
|
export class NestLogger implements LoggerService {
|
|
|
|
/**
|
|
|
|
* Write a 'log' level log.
|
|
|
|
*/
|
|
|
|
log(message: any, ...optionalParams: any[]) {
|
|
|
|
const ctx = optionalParams[0];
|
|
|
|
nestLogger.info(ctx + ': ' + message);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Write an 'error' level log.
|
|
|
|
*/
|
|
|
|
error(message: any, ...optionalParams: any[]) {
|
|
|
|
const ctx = optionalParams[0];
|
|
|
|
nestLogger.error(ctx + ': ' + message);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Write a 'warn' level log.
|
|
|
|
*/
|
|
|
|
warn(message: any, ...optionalParams: any[]) {
|
|
|
|
const ctx = optionalParams[0];
|
|
|
|
nestLogger.warn(ctx + ': ' + message);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Write a 'debug' level log.
|
|
|
|
*/
|
|
|
|
debug?(message: any, ...optionalParams: any[]) {
|
|
|
|
if (process.env.NODE_ENV === 'production') return;
|
|
|
|
const ctx = optionalParams[0];
|
|
|
|
nestLogger.debug(ctx + ': ' + message);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Write a 'verbose' level log.
|
|
|
|
*/
|
|
|
|
verbose?(message: any, ...optionalParams: any[]) {
|
|
|
|
if (process.env.NODE_ENV === 'production') return;
|
|
|
|
const ctx = optionalParams[0];
|
|
|
|
nestLogger.debug(ctx + ': ' + message);
|
|
|
|
}
|
|
|
|
}
|