Fixes
This commit is contained in:
22
src/main.ts
22
src/main.ts
@@ -8,10 +8,18 @@ import { AppModule } from './app.module';
|
||||
import { Logger as PinoLogger } from 'nestjs-pino';
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule, { bufferLogs: true });
|
||||
const pinoLogger = app.get(PinoLogger);
|
||||
app.useLogger(pinoLogger);
|
||||
const logger = new Logger('Bootstrap');
|
||||
// Create app with default logger first
|
||||
const app = await NestFactory.create(AppModule, {
|
||||
logger: ['error', 'warn', 'log', 'debug', 'verbose'],
|
||||
});
|
||||
|
||||
// Then set up Pino logger
|
||||
const pinoLogger = app.get(PinoLogger, { strict: false });
|
||||
if (pinoLogger) {
|
||||
app.useLogger(pinoLogger);
|
||||
}
|
||||
|
||||
const logger = app.get(Logger);
|
||||
const reflector = app.get(Reflector);
|
||||
|
||||
// Global pipes and interceptors
|
||||
@@ -48,8 +56,8 @@ async function bootstrap() {
|
||||
}
|
||||
}
|
||||
|
||||
bootstrap().catch((err) => {
|
||||
const logger = new Logger('Bootstrap');
|
||||
logger.error('Failed to start application', err);
|
||||
bootstrap().catch((error) => {
|
||||
// Use console.error here since the logger might not be available
|
||||
console.error('Failed to start application', error);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user