diff options
Diffstat (limited to 'lib/debug-utils.ts')
| -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); } } |
