All files / packages/sds-release-manager/src/utils logger.ts

100% Statements 8/8
100% Branches 0/0
72.72% Functions 8/11
100% Lines 8/8

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                        7x 5x 1x 1x 2x 3x 1x           2x    
import chalk from 'chalk';
 
export type Logger = {
  info: (msg: string) => void;
  step: (msg: string) => void;
  success: (msg: string) => void;
  warn: (msg: string) => void;
  error: (msg: string) => void;
  dryRun: (msg: string) => void;
};
 
export function createLogger(): Logger {
  return {
    info: (msg) => console.log(msg),
    step: (msg) => console.log(chalk.cyan(`→ ${msg}`)),
    success: (msg) => console.log(chalk.green(`✓ ${msg}`)),
    warn: (msg) => console.log(chalk.yellow(`⚠ ${msg}`)),
    error: (msg) => console.error(chalk.red(`✗ ${msg}`)),
    dryRun: (msg) => console.log(chalk.gray(`  [dry-run] ${msg}`)),
  };
}
 
// Silence step/info/success chatter (e.g. a service's own progress logs) while keeping warn/error visible.
export function quietLogger(logger: Logger): Logger {
  return { ...logger, step: () => {}, info: () => {}, success: () => {} };
}