Module: HourlyLoggerRotator

Defined in:
lib/hourly_logger_rotator.rb,
lib/hourly_logger_rotator/version.rb,
lib/hourly_logger_rotator/patch/ruby_2_3.rb,
lib/hourly_logger_rotator/patch/ruby_2_4.rb,
lib/hourly_logger_rotator/patch/ruby_2_5.rb

Defined Under Namespace

Modules: Patch

Constant Summary collapse

VERSION =
"0.2.0"

Class Method Summary collapse

Class Method Details

.add_hourly_rotation_period_support!Object



11
12
13
14
15
16
17
# 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) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# 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