class Tengine::Support::Config::Logger

Attributes

formatter[RW]

formatterにはprocしか設定できないので特別設定ファイルやコマンドラインオプションで指定することはできません。 もしformatteを指す名前を指定したい場合は、別途定義したfieldをから求めたformatterの値を、 オーバーライドしたnew_loggerで設定するようにしてください。

Public Instance Methods

new_logger(options = {}) click to toggle source

field :formatter, 'Logging formatter, as a Proc that will take four arguments and return the formatted message.',

:type => :proc, :hidden => true
# File lib/tengine/support/config/logger.rb, line 48
def new_logger(options = {})
  options = ActiveSupport::HashWithIndifferentAccess.new(to_hash).update(options || {})
  case output = options[:output]
  when "NULL" then return Tengine::Support::NullLogger.new
  when "STDOUT" then dev = STDOUT
  when "STDERR" then dev = STDERR
  else dev = output
  end
  rotation = options[:rotation]
  shift_age = (rotation =~ /\A\d+\Z/) ? rotation.to_i : rotation
  dtf = options[:datetime_format]
  result = ::Logger.new(dev, shift_age, options[:rotation_size])
  result.formatter = (options[:formatter] || dtf) ? Logger::Formatter.new : nil
  result.datetime_format = dtf if dtf
  result.level = ::Logger.const_get(options[:level].to_s.upcase)
  progname = options[:progname]
  result.progname = progname if progname
  result
end