$ show winstonjs/winston
Winston is a mature, widely-used logging library for Node.js. It provides a flexible, stream-based architecture where loggers are Transform streams and transports are Writable streams. The core Logger class accepts an `info` object (with `level` and `message`), passes it through a configurable format pipeline (from the `logform` package), and writes the result to one or more transports (e.g., Console, File, HTTP, Stream). The library supports custom log levels, child loggers, exception/rejection handling, profiling, and querying/streaming of logs. It is designed to be extensible: custom formats and transports can be created without modifying core code. External dependencies include `logform`, `winston-transport`, `triple-beam`, `safe-stable-stringify`, and `@dabh/diagnostics`. The codebase is well-structured, uses ES6 classes, and has comprehensive test coverage. It is actively maintained with regular releases and dependency updates.
The LLM identified 3 files worth highlighting for reuse:
Handles `uncaughtException` events by logging detailed error information (process info, OS info, stack trace) to configured transports. Demonstrates a clean pattern for capturing and logging uncaught exceptions with graceful exit control. Reusable in any Node.js application that needs robust exception logging.
Handles `unhandledRejection` events analogously to the exception handler. Logs rejection details with process and OS info. Provides a reusable pattern for logging unhandled promise rejections with configurable exit behavior.
Implements an inversion-of-control container for managing multiple named Logger instances. Supports lazy creation, shared options, and automatic cleanup on close. A clean, reusable pattern for managing singleton or named logger instances across an application.