File size: 743 Bytes
78013c4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
type LogLevel = 'debug' | 'info' | 'warn' | 'error';

const PREFIX: Record<LogLevel, string> = {
  debug: '⚫',
  info: '🔵',
  warn: '🟡',
  error: '🔴',
};

export const logger = {
  debug(message: string, ...args: unknown[]) {
    if (process.env.NODE_ENV === 'development') {
      console.debug(`${PREFIX.debug} ${message}`, ...args);
    }
  },
  info(message: string, ...args: unknown[]) {
    if (process.env.NODE_ENV === 'development') {
      console.info(`${PREFIX.info} ${message}`, ...args);
    }
  },
  warn(message: string, ...args: unknown[]) {
    console.warn(`${PREFIX.warn} ${message}`, ...args);
  },
  error(message: string, ...args: unknown[]) {
    console.error(`${PREFIX.error} ${message}`, ...args);
  },
};