Sha256: 6a4842381e6ee033a98b18f89b25ba5a0206c6a5b250c9aa22c0af88a6b5703f

Contents?: true

Size: 745 Bytes

Versions: 2

Compression:

Stored size: 745 Bytes

Contents

require 'tengine/support/config'

class Tengine::Support::Config::Logger
  include Tengine::Support::Config::Definition

  field :output, 'file path or "STDOUT" / "STDERR".', :type => :string
  field :rotation, 'rotation file count or daily,weekly,monthly.', :type => :string
  field :rotation_size, 'number of max log file size.', :type => :integer
  field :level, 'debug/info/warn/error/fatal.', :type => :string

  def new_logger
    case output
    when "STDOUT" then dev = STDOUT
    when "STDERR" then dev = STDERR
    else dev = output
    end
    shift_age = (rotation =~ /\A\d+\Z/) ? rotation.to_i : rotation
    result = Logger.new(dev, shift_age, rotation_size)
    result.level = Logger.const_get(level.upcase)
    result
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tengine_support-0.3.4 lib/tengine/support/config/logger.rb
tengine_support-0.3.3 lib/tengine/support/config/logger.rb