File size: 723 Bytes
1a12d36
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
/**

 * Lightweight logger that silences verbose output in production.

 *

 * - `log` / `debug` are only emitted when `import.meta.env.DEV` is true.

 * - `warn` and `error` always go through so real issues surface in prod.

 */

const isDev = import.meta.env.DEV;

/* eslint-disable no-console */
export const logger = {
  /** Debug-level log — DEV only. */
  log: (...args: unknown[]) => {
    if (isDev) console.log(...args);
  },
  /** Debug-level log — DEV only. */
  debug: (...args: unknown[]) => {
    if (isDev) console.debug(...args);
  },
  /** Warning — always emitted. */
  warn: console.warn.bind(console),
  /** Error — always emitted. */
  error: console.error.bind(console),
};