All files / utils logger.ts

100% Statements 7/7
100% Branches 3/3
100% Functions 3/3
100% Lines 5/5

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              2x             4x             2x 4x   2x          
import { COLORS } from './colors';
 
/**
 * Print error message in the terminal.
 * @param payload message payload
 * @param title message title
 */
const printSuccess = <T>(payload: T, title = 'Success') => console.log(`\n ✅ ${COLORS.GREEN}%s${COLORS.DEFAULT}:\n%s\n`, title, payload);
 
/**
 * Print info message in the terminal.
 * @param payload message payload
 * @param title message title
 */
const printInfo = <T>(payload: T, title = 'Info') => console.log(`\n 💬 ${COLORS.YELLOW}%s${COLORS.DEFAULT}:\n%s\n`, title, payload);
 
/**
 * Print error message in the terminal.
 * @param payload message payload
 * @param title message title
 */
const printError = <T>(payload?: Error & T, title = 'Error') =>
  console.log(`\n ❌ ${COLORS.RED}%s${COLORS.DEFAULT}:\n%s\n`, title, payload?.stack);
 
export const logger = {
  printSuccess,
  printInfo,
  printError,
};