Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 29 30 31 32 33 34 35 | 2x 3x 3x 3x | // TestLogger.ts
// Centralized logger for tests with log-level abstraction
export type LogLevel = 'DEBUG' | 'INFO' | 'ERROR';
const LOG_LEVEL: LogLevel = (process.env.LOG_LEVEL as LogLevel) || 'ERROR';
function shouldLog(level: LogLevel): boolean {
const levels: LogLevel[] = ['DEBUG', 'INFO', 'ERROR'];
return levels.indexOf(level) >= levels.indexOf(LOG_LEVEL);
}
export class TestLogger {
static debug(...args: any[]) {
if (shouldLog('DEBUG')) {
// eslint-disable-next-line no-console
console.debug('[DEBUG]', ...args);
}
}
static info(...args: any[]) {
Iif (shouldLog('INFO')) {
// eslint-disable-next-line no-console
console.info('[INFO]', ...args);
}
}
static error(...args: any[]) {
if (shouldLog('ERROR')) {
// eslint-disable-next-line no-console
console.error('[ERROR]', ...args);
}
}
}
|