mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-26 19:53:59 -05:00
Switch to new buffered logger
NestJS 8 allows the logs to buffer on startup, so that all logs run through our custom logger. See also https://docs.nestjs.com/techniques/logger#dependency-injection Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
2a382d0fe6
commit
ab231e0f6e
2 changed files with 9 additions and 2 deletions
|
@ -4,7 +4,13 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { Inject, Injectable, Optional, Scope } from '@nestjs/common';
|
||||
import {
|
||||
Inject,
|
||||
Injectable,
|
||||
LoggerService,
|
||||
Optional,
|
||||
Scope,
|
||||
} from '@nestjs/common';
|
||||
import { isObject } from '@nestjs/common/utils/shared.utils';
|
||||
import clc = require('cli-color');
|
||||
import DateTimeFormatOptions = Intl.DateTimeFormatOptions;
|
||||
|
@ -13,7 +19,7 @@ import { Loglevel } from '../config/loglevel.enum';
|
|||
import { needToLog } from '../config/utils';
|
||||
|
||||
@Injectable({ scope: Scope.TRANSIENT })
|
||||
export class ConsoleLoggerService {
|
||||
export class ConsoleLoggerService implements LoggerService {
|
||||
private classContext: string | undefined;
|
||||
private lastTimestamp: number;
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ import { ConsoleLoggerService } from './logger/console-logger.service';
|
|||
async function bootstrap(): Promise<void> {
|
||||
const app = await NestFactory.create<NestExpressApplication>(AppModule, {
|
||||
logger: ['error', 'warn', 'log'] as LogLevel[],
|
||||
bufferLogs: true,
|
||||
});
|
||||
const logger = await app.resolve(ConsoleLoggerService);
|
||||
logger.log('Switching logger', 'AppBootstrap');
|
||||
|
|
Loading…
Reference in a new issue