()
| 18 | } |
| 19 | |
| 20 | const createClientLogger = () => { |
| 21 | const currentLevel = getLogLevel() |
| 22 | |
| 23 | return { |
| 24 | debug: (message: string, meta?: any) => { |
| 25 | if (shouldLog('debug', currentLevel)) { |
| 26 | if (process.env.NODE_ENV !== 'production') { |
| 27 | console.log(`[DEBUG] ${message}`, meta || '') |
| 28 | } |
| 29 | } |
| 30 | }, |
| 31 | |
| 32 | info: (message: string, meta?: any) => { |
| 33 | if (shouldLog('info', currentLevel)) { |
| 34 | if (process.env.NODE_ENV !== 'production') { |
| 35 | console.info(`[INFO] ${message}`, meta || '') |
| 36 | } |
| 37 | } |
| 38 | }, |
| 39 | |
| 40 | warn: (message: string, meta?: any) => { |
| 41 | if (shouldLog('warn', currentLevel)) { |
| 42 | console.warn(`[WARN] ${message}`, meta || '') |
| 43 | } |
| 44 | }, |
| 45 | |
| 46 | error: (message: string, meta?: any) => { |
| 47 | if (shouldLog('error', currentLevel)) { |
| 48 | console.error(`[ERROR] ${message}`, meta || '') |
| 49 | } |
| 50 | } |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | export const clientLogger = createClientLogger() |
| 55 | export type ClientLogger = typeof clientLogger |
no test coverage detected