Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate Logging from Winston to Pino #3834

Closed
11 tasks done
Pyatakov opened this issue Jun 26, 2024 · 0 comments
Closed
11 tasks done

Migrate Logging from Winston to Pino #3834

Pyatakov opened this issue Jun 26, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request technical task

Comments

@Pyatakov
Copy link
Collaborator

Pyatakov commented Jun 26, 2024

Problem description

Our current logging system utilizes winston, which has served us well but has limitations in terms of performance and structured logging capabilities. As our application grows, we need a more efficient and feature-rich logging solution. Pino offers better performance, structured logging out of the box, and is more aligned with our future scalability needs.
Additionally, we are currently using Fastify as our web framework, which uses Pino as its default logger. By migrating our application logging to Pino, we can achieve better integration and consistency across our stack, leading to several benefits:

  1. Unified logging: Consistent logging format and methodology across both application and server logs.
  2. Improved performance: Pino is known for its low overhead, which aligns well with Fastify's performance-focused design.
  3. Better integration with Fastify ecosystem: Many Fastify plugins and tools are designed to work seamlessly with Pino logs.
  4. Simplified configuration: We can use a single configuration for both Fastify and our application logging.
  5. Enhanced debugging: With unified logging, it's easier to trace requests through our entire system.

Requirements

  • Replace winston with pino as the primary logging library across the entire application.
  • Refactor all existing log statements to use pino's syntax and features.
  • Configure pino to match or improve upon our current logging levels and formats.
  • Implement any custom logging functions or wrappers necessary to maintain current functionality.
  • Ensure all error tracking and monitoring systems are compatible with the new logging format.
  • Update documentation to reflect the new logging practices and usage.
  • Integrate application logging with Fastify's Pino instance for unified logging.
  • Configure serializers and redaction rules (if needed) to protect sensitive data consistently across server and application logs.
  • Implement a flexible logging output system that allows easy configuration for multiple targets:
    • File output
    • Database storage (MongoDB)
    • Integration with search and analysis applications (e.g., Seq)
    • Console output for development environments

Definition of done

  • All instances of winston have been removed from the codebase and replaced with pino.
  • All log statements throughout the application are using pino correctly.
  • Log output matches or exceeds the quality and detail of the previous winston implementation.
  • Performance metrics show improved logging efficiency.
  • Documentation has been updated to reflect the new logging practices.
  • Fastify and application logs are unified and consistent.
  • Logging configuration is streamlined, using Fastify's Pino instance where appropriate.
  • Logging output can be easily configured for different targets (files, database, analysis tools) without (or with minimal) code changes.

Acceptance criteria

  • No winston imports or usage remain in the codebase.
  • All log levels (error, warn, info, debug, etc.) are correctly implemented in pino.
  • Structured logging is being used effectively, with relevant metadata included in log entries.
  • Log files or log streams are being correctly generated and rotated as needed.
  • Integration tests pass, confirming that logging doesn't break any existing functionality.
  • Performance tests show that logging operations are at least as fast as before, preferably faster.
  • Developers can successfully use the new logging system in their local development environments.
  • Fastify server logs and application logs show a consistent format and are easily correlated.
  • Sensitive data is properly redacted in both server and application logs.
  • Logging output can be easily switched between file, database, and search/analysis app targets through configuration changes.
  • Documentation is provided on how to configure different logging outputs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request technical task
Projects
None yet
Development

No branches or pull requests

3 participants