Skip to content

Commit

Permalink
fix: use logger after listen
Browse files Browse the repository at this point in the history
  • Loading branch information
Innei committed Oct 3, 2021
1 parent eb04d31 commit b410e71
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/_bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand Down Expand Up @@ -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.')
})

Expand Down
2 changes: 2 additions & 0 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -101,6 +102,7 @@ mkdirs()

GatewayModule,
HelperModule,
LoggerModule,
],
controllers: [AppController],
providers: [
Expand Down
2 changes: 1 addition & 1 deletion src/common/interceptors/logging.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions src/processors/logger/logger.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Module } from '@nestjs/common'
import { MyLogger } from './logger.service'

@Module({ providers: [MyLogger], exports: [MyLogger] })
export class LoggerModule {}

0 comments on commit b410e71

Please sign in to comment.