Skip to content

Commit

Permalink
fix: 로거 타임아웃 설정, 테스트용 로깅 추가 #133
Browse files Browse the repository at this point in the history
  • Loading branch information
Miensoap committed Nov 16, 2024
1 parent a4c947f commit 1bd5f53
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion backend/src/app.controller.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { Controller, Get } from '@nestjs/common';
import { AppService } from './app.service';
import { PinoLogger } from 'nestjs-pino';

@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}
constructor(
private readonly logger: PinoLogger,
private readonly appService: AppService,
) {}

@Get()
async getHello() {
this.logger.info('Hello world');
return (await this.appService.getHello()) + ' Web 09 Backend';
}
}
6 changes: 5 additions & 1 deletion backend/src/common/log/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ const logstashLoggerOptions = {

export function createLogger(host: string, port: number) {
if (process.env.NODE_ENV === 'prod') {
const stream = net.createConnection({ host, port });
const stream = net.createConnection({ host, port, timeout: 5000 });
stream.on('error', (err) => {
console.error('Log Stream connection error:', err);

Check warning on line 53 in backend/src/common/log/logger.ts

View workflow job for this annotation

GitHub Actions / Lint, Build and Test (backend)

Unexpected console statement
});

return pino(logstashLoggerOptions, stream);
}
return pino(consoleLoggerOptions);
Expand Down

0 comments on commit 1bd5f53

Please sign in to comment.