Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@chtsinc/ch-logger

rthomas-chtsinc109MIT0.0.2TypeScript support: included

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

logger, winston, logging, typescript, npm-package, console, file, custom-logger

readme

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 .