-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Config] 서버 로깅 설정 및 오류 포멧 설정 #44
Conversation
const { statusCode } = context.switchToHttp().getResponse(); | ||
const delay = Date.now() - now; | ||
this.logger.log( | ||
`[RESPONSE] ${method} ${url} ${ip} - ${statusCode} \x1b[33m+${delay}ms\x1b[0m` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟢
템플릿 리터럴이 길어지면 무슨 역할을 하는지 알아보기가 힘들어진다는 피드백을 받았던 적이 있습니다!
아직 짧아서 괜찮지만, createResponseLog
등의 함수로 분리하는 것도 좋아보입니다~~
import { tap } from 'rxjs'; | ||
|
||
@Injectable() | ||
export class HttpLoggingInterceptor implements NestInterceptor { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟢
클래스명과 파일명을 일치시키면 코드를 찾아가기가 좋을 것 같습니다.
그리고, import
시에도 더 용이할 것 같습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아 이 부분은 주의해야겠어요. 항상 파일이랑 클래스 이름 일치를 확인을 못하네요. 중간에 이름을 한번 바꾼거라..
아 추가로! 괜찮으시다면 하시던 작업 이후로는 레포지토리 클론 후 작업해주시면 감사하겠습니다!! |
@@ -2,9 +2,12 @@ import { Module } from '@nestjs/common'; | |||
import { TypeOrmModule } from '@nestjs/typeorm'; | |||
import { DataSource, DataSourceOptions } from 'typeorm'; | |||
import { ConfigModule } from '@nestjs/config'; | |||
import { APP_FILTER, APP_INTERCEPTOR } from '@nestjs/core'; | |||
import { TypeormConfig } from '../config/typeorm.config'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
단순 궁금증인데,
상대 경로 나열되면 불편하진 않으신가요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
절대 경로로 변경하는게 보기에 더 좋을까요? 이때까지 크게 불편함을 크게 느끼지 못해서 계속 사용하고 있었는데 수정해야겠네요
관련 이슈 번호
#2
작업 내용
고민과 학습내용
서버에서 http 요청이 올때 간단하게 로그를 남기고 응답을 할때나 오류가 발생했을때도 로그를 남기도록 설정했습니다.