MCPcopy
hub / github.com/node-cron/node-cron / log

Function log

src/logger.ts:25–46  ·  view source on GitHub ↗
(level: LogLevel, message: string, extra?: any)

Source from the content-addressed store, hash-verified

23const RESET = '\x1b[0m';
24
25function log(level: LogLevel, message: string, extra?: any): void {
26 const timestamp = new Date().toISOString();
27 const color = levelColors[level] ?? '';
28 const prefix = `[${timestamp}] [PID: ${process.pid}] ${GREEN}[NODE-CRON]${GREEN} ${color}[${level}]${RESET}`;
29 const output = `${prefix} ${message}`;
30
31 switch (level) {
32 case 'ERROR':
33 console.error(output, extra ?? '');
34 break;
35 case 'DEBUG':
36 console.debug(output, extra ?? '');
37 break;
38 case 'WARN':
39 console.warn(output);
40 break;
41 case 'INFO':
42 default:
43 console.info(output);
44 break;
45 }
46}
47
48/**
49 * The built-in console logger. Used by default unless replaced via `setLogger`.

Callers 4

infoFunction · 0.85
warnFunction · 0.85
errorFunction · 0.85
debugFunction · 0.85

Calls 4

errorMethod · 0.80
debugMethod · 0.80
warnMethod · 0.80
infoMethod · 0.80

Tested by

no test coverage detected