A Pino-based structured logger for NestJS applications with file rotation, pretty printing, and comprehensive TypeScript support.
@shinijs/logger is a fast, low-overhead structured logging solution designed specifically for the NestJS ecosystem. Built on top of Pino, one of the fastest logging libraries in the Node.js ecosystem, it provides beautiful colorized console output during development and efficient JSON-structured logging for production environments.
The library seamlessly integrates with NestJS through dependency injection, offering both traditional NestJS LoggerService patterns and a flexible LoggerFactory approach. It includes automatic daily log file rotation, ensuring your logs are organized and manageable over time. The context-aware logging system allows you to create scoped loggers that automatically tag all messages with relevant context information for better debugging and tracing.
Built with TypeScript-first principles, the library provides full type safety and IntelliSense support throughout. Configuration is entirely environment-based with sensible defaults, making it trivial to switch between development and production logging modes. The library also integrates seamlessly with other @shinijs packages, particularly @shinijs/rate-limit, for comprehensive application monitoring.
@shinijs/logger follows a modular architecture designed for the NestJS ecosystem. The core LoggerModule is a global module that can be imported once in your root module and used throughout your application. It provides two primary patterns: a traditional dependency injection approach using the LoggerService interface, and a factory pattern using LoggerFactory for more flexible use cases. The library uses environment variables for configuration (LOG_LEVEL, LOG_PRETTY_PRINT, LOG_FILE_ENABLED, LOG_FILE_PATH), allowing seamless transitions between development and production environments. File logging uses daily rotation to prevent log files from growing unbounded, with timestamps in filenames for easy organization.
Solution: Chose Pino as the underlying engine for its exceptional performance (low overhead and fast JSON serialization) while building an ergonomic NestJS wrapper around it with features like context support and pretty printing
Solution: Implemented environment-based configuration that automatically switches between pino-pretty colorized output for development and raw JSON structured logging for production, with all settings controlled via environment variables
Solution: Designed dual integration patterns: LoggerService for traditional dependency injection (following NestJS conventions) and LoggerFactory for factory pattern usage, giving developers flexibility in how they consume the logger
Solution: Implemented automatic daily log file rotation with timestamp-based filenames, preventing unbounded file growth while maintaining organized historical logs that can be archived or cleaned up based on retention policies
Professional car detailing and furniture cleaning service website offering comprehensive cleaning solutions with modern Polish interface.
Professional electrical and construction services company website showcasing comprehensive solutions with modern Polish interface.
A streaming platform for finding and watching anime series and movies with Polish subtitles.