class

Logarithm::LogManager

Inherits Reference < Object

Log file management and rotation system

This module provides comprehensive log file management including:

  • Automatic log rotation based on size or time
  • Configurable retention policies
  • Log compression and archiving
  • Cleanup of old log files

Features

  • Size-based rotation: Rotate logs when they exceed a size limit
  • Time-based rotation: Rotate logs at specified intervals (daily, weekly, monthly)
  • Retention policies: Keep logs for specified periods
  • Compression: Compress old log files to save space
  • Cleanup: Automatically remove logs beyond retention period

Configuration

log_rotation:
  max_size_mb: 100
  rotation_interval: "daily"  # daily, weekly, monthly
  retention_days: 30
  compress_after_days: 7
  max_rotations: 10

Constructors

new(config : Logarithm::LogManager::LogRotationConfig = LogRotationConfig.new)
Source

Instance methods

cleanup_retention(log_file : String)

Clean up logs beyond retention period

Source
compress_old_logs(log_file : String)

Compress old log files

Source
config
Source
get_log_stats(log_file : String) : Hash(String, JSON::Any)

Get log file statistics

Source
needs_rotation?(log_file : String) : Bool

Check if log file needs rotation

Source
perform_maintenance(log_files : Array(String))

Perform maintenance on all log files

Source
rotate_log(log_file : String) : Bool

Rotate a log file

Source

Nested types