1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
// 개발 환경 디버그 유틸리티
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: unknown[]) {
if (isDebugEnabled) {
console.log(`🔍 [${getTimestamp()}] ${message}`, ...args);
}
}
/**
* 개발 환경에서만 console.error 출력
*/
export function debugError(message: string, ...args: unknown[]) {
if (isDebugEnabled) {
console.error(`❌ [${getTimestamp()}] ${message}`, ...args);
}
}
/**
* 개발 환경에서만 console.warn 출력
*/
export function debugWarn(message: string, ...args: unknown[]) {
if (isDebugEnabled) {
console.warn(`⚠️ [${getTimestamp()}] ${message}`, ...args);
}
}
/**
* 개발 환경에서만 성공 로그 출력
*/
export function debugSuccess(message: string, ...args: unknown[]) {
if (isDebugEnabled) {
console.log(`✅ [${getTimestamp()}] ${message}`, ...args);
}
}
/**
* 개발 환경에서만 프로세스 로그 출력
*/
export function debugProcess(message: string, ...args: unknown[]) {
if (isDebugEnabled) {
console.log(`🔐 [${getTimestamp()}] ${message}`, ...args);
}
}
/**
* 개발 환경에서만 Mock 모드 로그 출력
*/
export function debugMock(message: string, ...args: unknown[]) {
if (isDebugEnabled) {
console.log(`🎭 [${getTimestamp()}] ${message}`, ...args);
}
}
/**
* 개발 환경 여부 확인
*/
export function isDevMode(): boolean {
return isDev;
}
/**
* 디버그 모드 여부 확인 (DEBUG=true 또는 NODE_ENV=development)
*/
export function isDebugMode(): boolean {
return isDebugEnabled;
}
|