nest-winston
nest-winston copied to clipboard
setLogLevels is not a function
Hey,
nestjs - 8.4.7 nest-winston - 1.6.2 winston - 3.8.0
On running npm run start:dev
. I get the following error:
(node:75942) UnhandledPromiseRejectionWarning: TypeError: _a.setLogLevels is not a function
at Function.overrideLogger (/node_modules/@nestjs/common/services/logger.service.js:121:90)
at NestFactoryStatic.registerLoggerConfiguration (/node_modules/@nestjs/core/nest-factory.js:141:37)
at NestFactoryStatic.createApplicationContext (/node_modules/@nestjs/core/nest-factory.js:72:14)
at Function.runApplication (/packages/nest-commander/src/command.factory.ts:43:35)
at Function.run (/packages/nest-commander/src/command.factory.ts:20:28)
at bootstrap (/src/main.ts:28:24)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
main.ts
-> bootstrap
function has:
const app = await NestFactory.create(AppModule);
app.useLogger(WinstonModule.createLogger({
format: winston.format.uncolorize(),
transports: [
new winston.transports.Console({
format: winston.format.combine(
winston.format.timestamp({
format: 'YYYY-MM-DD HH:mm:ss',
}),
winston.format.ms(),
nestWinstonModuleUtilities.format.nestLike()
),
})
]
}));
Error seems to be thrown from nest's logger service calling _a.setLogLevels(logger)
:
static overrideLogger(logger) {
var _a;
if (Array.isArray(logger)) {
Logger_1.logLevels = logger;
return (_a = this.staticInstanceRef) === null || _a === void 0 ? void 0 : _a.setLogLevels(logger);
}
if ((0, shared_utils_1.isObject)(logger)) {
if (logger instanceof Logger_1 && logger.constructor !== Logger_1) {
const errorMessage = `Using the "extends Logger" instruction is not allowed in Nest v8. Please, use "extends ConsoleLogger" instead.`;
this.staticInstanceRef.error(errorMessage);
throw new Error(errorMessage);
}
this.staticInstanceRef = logger;
}
else {
this.staticInstanceRef = undefined;
}
}
Would really appreciate anyone showing some light on how I could get passed this issue? Thanks.