UNPKG

@chtsinc/ch-logger

Version:

Reusable Winston-based logger for CH npm packages with support for console, file logging, and custom logger injection.

52 lines (40 loc) • 1.28 kB
README.md md Copy Edit # ch-logger A reusable, Winston-based logging utility for Node.js/TypeScript packages at CH. Supports: - Console logging by default - Optional file logging via environment variables - Log level control via `LOG_LEVEL` - Custom logger injection for full flexibility --- ## šŸš€ Installation ```bash npm install ch-logger šŸ“¦ Usage āœ… Default Logger (Console) ts import { getLogger } from 'ch-logger'; const logger = getLogger(); logger.info('Hello from ch-logger!'); šŸ” Custom Logger Injection ts import winston from 'winston'; import { getLogger } from 'ch-logger'; const custom = winston.createLogger({ level: 'debug', transports: [new winston.transports.Console()] }); const logger = getLogger(custom); logger.debug('Using injected logger'); āš™ļø Environment Variables You can control logging behavior using .env or process.env: Variable Description Example LOG_LEVEL Sets log level (debug, info, etc.) LOG_LEVEL=debug LOG_TO_FILE Enables file logging (true or false) LOG_TO_FILE=true LOG_FILE Log file path (default: app.log) LOG_FILE=logs/app.log šŸ“ Output Example 2025-04-16T13:45:33.125Z [INFO] Starting ch-uploader... 2025-04-16T13:45:34.456Z [DEBUG] Uploading file: invoice.pdf .