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

[Hackathon] Implement Log Rotation in logger.go #499

Open
6 tasks
rsdmike opened this issue Feb 10, 2025 · 0 comments
Open
6 tasks

[Hackathon] Implement Log Rotation in logger.go #499

rsdmike opened this issue Feb 10, 2025 · 0 comments

Comments

@rsdmike
Copy link
Member

rsdmike commented Feb 10, 2025

🏆 Hackathon Task: Implement Log Rotation in logger.go

🔹 Overview

The console project currently logs events using zerolog, but it does not support log rotation. We want to enhance our logging system by adding log rotation capabilities to prevent log files from growing indefinitely.

This task involves updating pkg/logger/logger.go to:

  1. Enable log rotation using best practices.
  2. Allow key rotation parameters to be configurable via environment variables.
  3. Ensure backward compatibility with the existing logging structure.

🎯 Task Scope

  • Step 1: Update pkg/logger/logger.go to integrate log rotation.
  • Step 2: Use lumberjack.Logger (or an alternative) to handle file rotation.
  • Step 3: Ensure that rotation settings (e.g., max size, max backups, max age, compression) can be configured via environment variables.
  • Step 4: Implement sane defaults if environment variables are not set.
  • Step 5: Update the logger initialization to use a structured format for logs, maintaining compatibility with zerolog.
  • Step 6: Test the logging behavior by simulating log growth and verifying that rotation works as expected.

📂 Relevant Files

  • pkg/logger/logger.go
  • cmd/main.go (may need minor updates for initialization)
  • config/config.go (if adding environment variables)

💻 Technical Details

  • Use zerolog as the logging framework.
  • For log rotation, consider integrating:
    • lumberjack.Logger (widely used and recommended)
    • OR another equivalent solution if necessary.
  • Configurable Environment Variables:
    LOG_FILE_PATH=/var/log/amt-console.log
    LOG_MAX_SIZE=10  # Max file size in MB before rotation
    LOG_MAX_BACKUPS=5  # Max number of rotated log files
    LOG_MAX_AGE=7  # Days to keep old logs
    LOG_COMPRESS=true  # Whether to compress rotated logs
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

1 participant