File: date_rolling_log_file.rb

package info (click to toggle)
ruby-lumberjack 2.0.4-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 956 kB
  • sloc: ruby: 7,957; makefile: 2
file content (22 lines) | stat: -rw-r--r-- 776 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true

require "date"

module Lumberjack
  # Deprecated device. Use LogFile instead.
  #
  # @deprecated Use Lumberjack::Device::LogFile
  class Device::DateRollingLogFile < Device::LogFile
    def initialize(path, options = {})
      Utils.deprecated("Lumberjack::Device::DateRollingLogFile", "Lumberjack::Device::DateRollingLogFile is deprecated and will be removed in version 2.1; use Lumberjack::Device::LogFile instead.")

      unless options[:roll]&.to_s&.match(/(daily)|(weekly)|(monthly)/i)
        raise ArgumentError.new("illegal value for :roll (#{options[:roll].inspect})")
      end

      new_options = options.reject { |k, _| k == :roll }.merge(shift_age: options[:roll].to_s.downcase)

      super(path, new_options)
    end
  end
end