UNPKG

node-logger-light

Version:

An advanced logging library for Node.js with support for different log levels, file logging, and external services integration.

23 lines (22 loc) 808 B
//filename: ConsoleTransport.ts import winston from 'winston'; import chalk from 'chalk'; export class ConsoleTransport extends winston.transports.Console { constructor(logLevel) { super({ level: logLevel, format: winston.format.printf(({ level, message }) => { // Define the available colors in Chalk const colors = { info: 'green', warn: 'yellow', error: 'red', debug: 'cyan', }; // Access chalk color function with proper type assertion const color = colors[level] || 'white'; // Default to 'white' if not found return `${chalk[color](level)}: ${message}`; }), }); } }