File: size_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-- 944 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

module Lumberjack
  # Deprecated device. Use LogFile instead.
  #
  # @deprecated Use Lumberjack::Device::LogFile
  class Device::SizeRollingLogFile < Device::LogFile
    attr_reader :max_size

    # Create an new log device to the specified file. The maximum size of the log file is specified with
    # the :max_size option. The unit can also be specified: "32K", "100M", "2G" are all valid.
    def initialize(path, options = {})
      Utils.deprecated("Lumberjack::Device::SizeRollingLogFile", "Lumberjack::Device::SizeRollingLogFile is deprecated and will be removed in version 2.1; use Lumberjack::Device::LogFile instead.")

      @max_size = options[:max_size]
      new_options = options.reject { |k, _| k == :max_size }.merge(shift_size: max_size)
      new_options[:shift_age] = 10 unless options[:shift_age].is_a?(Integer) && options[:shift_age] >= 0

      super(path, new_options)
    end
  end
end