module HourlyLoggerRotator

Constants

VERSION

Public Class Methods

add_hourly_rotation_period_support!() click to toggle source
# File lib/hourly_logger_rotator.rb, line 11
def add_hourly_rotation_period_support!
  if hourly_mixin
    Logger::LogDevice.prepend(hourly_mixin)
  else
    warn unsupported_warning
  end
end
default_rotation_period=(period) click to toggle source
Calls superclass method
# File lib/hourly_logger_rotator.rb, line 19
def default_rotation_period=(period)
  raise unsupported_warning if period == "hourly" && !hourly_mixin

  mixin = Module.new do
    define_method(:initialize) do |logdev, shift_age = period, *args|
      super(logdev, shift_age, *args)
    end
  end

  Logger.prepend(mixin)
end

Private Class Methods

hourly_mixin() click to toggle source
# File lib/hourly_logger_rotator.rb, line 33
def hourly_mixin
  return @mixin if defined?(@mixin)

  mixin_name = "HourlyLoggerRotator::Patch::Ruby_#{RUBY_VERSION.split('.').first(2).join('_')}"

  @mixin =
    begin
      Module.const_get(mixin_name)
    rescue NameError
      nil
    end
end
unsupported_warning() click to toggle source
# File lib/hourly_logger_rotator.rb, line 46
def unsupported_warning
  "Hourly log rotation period is not supported for Ruby #{RUBY_VERSION}"
end