Skip to content

디버깅 로그 추가#22

Merged
chungjeongsu merged 1 commit into
developfrom
chore/logs
Apr 7, 2026
Merged

디버깅 로그 추가#22
chungjeongsu merged 1 commit into
developfrom
chore/logs

Conversation

@chungjeongsu

Copy link
Copy Markdown
Contributor

No description provided.

@chungjeongsu chungjeongsu self-assigned this Apr 7, 2026
@chungjeongsu chungjeongsu merged commit 3dae275 into develop Apr 7, 2026
2 checks passed

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces comprehensive logging for the WebSocket server, covering connection upgrades, authentication results, room reservations, and connection lifecycle events. It also adds utility methods for gathering log context and sanitizing URLs by redacting sensitive tokens. The reviewer suggests adopting a structured logging library like Winston or Pino for better observability, preserving error stack traces by passing error objects directly to loggers, and removing redundant log statements in the rejectUpgrade method to reduce noise.

Comment on lines +24 to +26
console.log(
`[ws upgrade] received url=${requestLog.url} remote=${requestLog.remoteAddress} host=${requestLog.host}`
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

운영 환경에서의 디버깅과 로그 관리를 위해 console.log 대신 winston이나 pino와 같은 구조화된 로거(Structured Logger) 사용을 권장합니다. 구조화된 로그를 사용하면 userId, travelDocId와 같은 필드를 개별 속성으로 저장할 수 있어, 나중에 로그 검색 및 분석이 훨씬 용이해집니다.

Comment on lines +110 to +112
console.error(
`[ws upgrade] handshake failed userId=${userId} travelDocId=${travelDocId} error=${error?.message ?? error}`
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

에러 로그 기록 시 error.message만 문자열에 포함하면 실제 에러의 스택 트레이스(Stack Trace) 정보를 잃게 됩니다. console.error의 두 번째 인자로 에러 객체를 직접 전달하면 더 상세한 디버깅 정보를 기록할 수 있습니다.

Suggested change
console.error(
`[ws upgrade] handshake failed userId=${userId} travelDocId=${travelDocId} error=${error?.message ?? error}`
);
console.error(
'[ws upgrade] handshake failed userId=' + userId + ' travelDocId=' + travelDocId,
error
);

Comment on lines +145 to +147
console.error(
`[ws connection] error userId=${userId} travelDocId=${travelDocId} error=${error?.message ?? error}`
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

위의 handleUpgrade 에러 로그와 마찬가지로, 에러 객체를 직접 전달하여 스택 트레이스를 포함한 전체 에러 컨텍스트를 유지하는 것이 좋습니다.

      console.error(
        '[ws connection] error userId=' + userId + ' travelDocId=' + travelDocId,
        error
      );

}

rejectUpgrade(socket, statusCode, message) {
console.warn(`[ws upgrade] responding status=${statusCode} message="${message}"`);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

rejectUpgrade 메서드 내부에 추가된 로그는 handleUpgrade에서 rejectUpgrade를 호출하기 직전에 이미 상세한 로그를 남기고 있어 중복됩니다. 로그 노이즈를 줄이기 위해 이 라인은 삭제하는 것을 권장합니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants