fix: use logger after listen

This commit is contained in:
Innei
2021-10-03 14:31:24 +08:00
parent eb04d31b7b
commit b410e71ce1
4 changed files with 9 additions and 3 deletions

View File

@@ -20,7 +20,6 @@ async function bootstrap() {
const app = await NestFactory.create<NestFastifyApplication>(
AppModule,
fastifyApp,
{ logger: new MyLogger() },
)
const hosts = Origin.map((host) => new RegExp(host, 'i'))
@@ -76,7 +75,7 @@ async function bootstrap() {
consola.success(`Admin Dashboard: ${url}/qaqdmin`)
consola.success(`Server listen on: ${url}`)
}
app.useLogger(app.get(MyLogger))
Logger.log('Server is up.')
})

View File

@@ -46,6 +46,7 @@ import { CacheModule } from './processors/cache/cache.module'
import { DbModule } from './processors/database/database.module'
import { GatewayModule } from './processors/gateway/gateway.module'
import { HelperModule } from './processors/helper/helper.module'
import { LoggerModule } from './processors/logger/logger.module'
// FIXME
function mkdirs() {
@@ -101,6 +102,7 @@ mkdirs()
GatewayModule,
HelperModule,
LoggerModule,
],
controllers: [AppController],
providers: [

View File

@@ -23,7 +23,7 @@ import { HTTP_REQUEST_TIME } from '~/constants/meta.constant'
export class LoggingInterceptor implements NestInterceptor {
private logger: Logger
constructor() {
this.logger = new Logger(LoggingInterceptor.name)
this.logger = new Logger(LoggingInterceptor.name, { timestamp: false })
}
intercept(
context: ExecutionContext,

View File

@@ -0,0 +1,5 @@
import { Module } from '@nestjs/common'
import { MyLogger } from './logger.service'
@Module({ providers: [MyLogger], exports: [MyLogger] })
export class LoggerModule {}