• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

node-cron / node-cron / 16895283675

12 Aug 2025 12:08AM UTC coverage: 89.256% (-7.8%) from 97.037%
16895283675

Pull #481

github

web-flow
Merge 39584aad7 into c76f95e92
Pull Request #481: build: using rollout

457 of 540 branches covered (84.63%)

Branch coverage included in aggregate %.

4 of 4 new or added lines in 2 files covered. (100.0%)

161 existing lines in 11 files now uncovered.

1595 of 1759 relevant lines covered (90.68%)

37.31 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

79.45
/src/logger.ts
1
type LogLevel = 'INFO' | 'WARN' | 'ERROR' | 'DEBUG';
1✔
2

1✔
3
const levelColors: Record<LogLevel, string> = {
1✔
4
  INFO: '\x1b[36m',   // Cyan
1✔
5
  WARN: '\x1b[33m',   // Yellow
1✔
6
  ERROR: '\x1b[31m',  // Red
1✔
7
  DEBUG: '\x1b[35m',  // Magenta
1✔
8
};
1✔
9

1✔
10
const GREEN = '\x1b[32m';
1✔
11
const RESET = '\x1b[0m';
1✔
12

1✔
13
function log(level: LogLevel, message: string, extra?: any): void {
2✔
14
  const timestamp = new Date().toISOString();
2✔
15
  const color = levelColors[level] ?? '';
2!
16
  const prefix = `[${timestamp}] [PID: ${process.pid}] ${GREEN}[NODE-CRON]${GREEN} ${color}[${level}]${RESET}`;
2✔
17
  const output = `${prefix} ${message}`;
2✔
18

1✔
19
  switch (level) {
1✔
20
    case 'ERROR':
1✔
21
      console.error(output, extra ?? '');
1!
22
      break;
1✔
23
    case 'DEBUG':
1!
24
        console.debug(output, extra ?? '');
1✔
25
        break;
1✔
26
    case 'WARN':
1✔
27
      console.warn(output);
1✔
28
      break;
1✔
29
    case 'INFO':
1✔
30
    default:
29✔
31
      console.info(output);
1✔
32
      break;
1✔
33
  }
1✔
34
}
1✔
35

1✔
36
const logger = {
1✔
37
  info(message: string) {
1✔
UNCOV
38
    log('INFO', message);
×
UNCOV
39
  },
×
40
  warn(message: string) {
1✔
41
    log('WARN', message);
1✔
42
  },
1✔
43
  error(message: string | Error, err?: Error) {
1✔
44
    if (message instanceof Error) {
2✔
45
      log('ERROR', message.message, message);
2✔
46
    } else {
29!
UNCOV
47
      log('ERROR', message, err);
×
UNCOV
48
    }
×
49
  },
2✔
50
  debug(message: string | Error, err?: Error) {
1✔
UNCOV
51
    if (message instanceof Error) {
×
UNCOV
52
      log('DEBUG', message.message, message);
×
UNCOV
53
    } else {
×
UNCOV
54
      log('DEBUG', message, err);
×
UNCOV
55
    }
×
UNCOV
56
  },
×
57
};
1✔
58

1✔
59
export default logger;
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc