You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
859 B
33 lines
859 B
import { LOGGER_LEVEL, LOGGER_WINSTON_PROVIDER } from './logger.constants';
|
|
import { createLogger, transports, format } from 'winston';
|
|
|
|
export const loggerProviders = [
|
|
{
|
|
provide: LOGGER_WINSTON_PROVIDER,
|
|
useFactory: () => {
|
|
const LOG_LEVEL = LOGGER_LEVEL.DEBUG;
|
|
|
|
const winstonTransports = [new transports.Console({})];
|
|
|
|
const winstonFormaters = format.combine(
|
|
format.colorize(),
|
|
format.timestamp({
|
|
format: 'YYYY-MM-DD HH:mm:ss',
|
|
}),
|
|
format.align(),
|
|
format.printf(
|
|
info =>
|
|
`[Nest] ${process.pid} - ${info.timestamp} ${
|
|
info.level
|
|
}: ${info.message.trim()}`,
|
|
),
|
|
);
|
|
|
|
return createLogger({
|
|
level: LOG_LEVEL,
|
|
transports: winstonTransports,
|
|
format: winstonFormaters,
|
|
});
|
|
},
|
|
},
|
|
];
|