diff options
| author | joonhoekim <26rote@gmail.com> | 2025-08-27 12:01:33 +0000 |
|---|---|---|
| committer | joonhoekim <26rote@gmail.com> | 2025-08-27 12:01:33 +0000 |
| commit | 7eac558470ef179dad626a8e82db5784fe86a556 (patch) | |
| tree | cc43dd715a37f3eef3c7e5d56ce00db9998d6b1a | |
| parent | e7b8ad6ebe3fd42d3511a9d346f72ce294210182 (diff) | |
(김준회) 디버그 유틸리티 시간표시하도록 개선
| -rw-r--r-- | lib/debug-utils.ts | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/lib/debug-utils.ts b/lib/debug-utils.ts index c64d5bb9..88b5f9fc 100644 --- a/lib/debug-utils.ts +++ b/lib/debug-utils.ts @@ -4,56 +4,71 @@ const isDev = process.env.NODE_ENV === 'development'; const isDebugEnabled = process.env.NEXT_PUBLIC_DEBUG === 'true' || isDev; /** + * 현재 시간을 YYYYMMDD-HHMMSS 형식으로 반환 + */ +function getTimestamp(): string { + const now = new Date(); + const year = now.getFullYear(); + const month = String(now.getMonth() + 1).padStart(2, '0'); + const day = String(now.getDate()).padStart(2, '0'); + const hours = String(now.getHours()).padStart(2, '0'); + const minutes = String(now.getMinutes()).padStart(2, '0'); + const seconds = String(now.getSeconds()).padStart(2, '0'); + + return `${year}${month}${day}-${hours}${minutes}${seconds}`; +} + +/** * 개발 환경에서만 console.log 출력 */ -export function debugLog(message: string, ...args: any[]) { +export function debugLog(message: string, ...args: unknown[]) { if (isDebugEnabled) { - console.log(`🔍 ${message}`, ...args); + console.log(`🔍 [${getTimestamp()}] ${message}`, ...args); } } /** * 개발 환경에서만 console.error 출력 */ -export function debugError(message: string, ...args: any[]) { +export function debugError(message: string, ...args: unknown[]) { if (isDebugEnabled) { - console.error(`❌ ${message}`, ...args); + console.error(`❌ [${getTimestamp()}] ${message}`, ...args); } } /** * 개발 환경에서만 console.warn 출력 */ -export function debugWarn(message: string, ...args: any[]) { +export function debugWarn(message: string, ...args: unknown[]) { if (isDebugEnabled) { - console.warn(`⚠️ ${message}`, ...args); + console.warn(`⚠️ [${getTimestamp()}] ${message}`, ...args); } } /** * 개발 환경에서만 성공 로그 출력 */ -export function debugSuccess(message: string, ...args: any[]) { +export function debugSuccess(message: string, ...args: unknown[]) { if (isDebugEnabled) { - console.log(`✅ ${message}`, ...args); + console.log(`✅ [${getTimestamp()}] ${message}`, ...args); } } /** * 개발 환경에서만 프로세스 로그 출력 */ -export function debugProcess(message: string, ...args: any[]) { +export function debugProcess(message: string, ...args: unknown[]) { if (isDebugEnabled) { - console.log(`🔐 ${message}`, ...args); + console.log(`🔐 [${getTimestamp()}] ${message}`, ...args); } } /** * 개발 환경에서만 Mock 모드 로그 출력 */ -export function debugMock(message: string, ...args: any[]) { +export function debugMock(message: string, ...args: unknown[]) { if (isDebugEnabled) { - console.log(`🎭 ${message}`, ...args); + console.log(`🎭 [${getTimestamp()}] ${message}`, ...args); } } |
