Class: Tengine::Support::Config::Logger
- Inherits:
-
Object
- Object
- Tengine::Support::Config::Logger
- Includes:
- Definition
- Defined in:
- lib/tengine/support/config/logger.rb
Instance Attribute Summary collapse
-
#formatter ⇒ Object
formatterにはprocしか設定できないので特別設定ファイルやコマンドラインオプションで指定することはできません。 もしformatteを指す名前を指定したい場合は、別途定義したfieldをから求めたformatterの値を、 オーバーライドしたnew_loggerで設定するようにしてください。.
Attributes included from Definition
#__name__, #__parent__, #children
Instance Method Summary collapse
-
#new_logger(options = {}) ⇒ Object
field :formatter, ‘Logging formatter, as a Proc that will take four arguments and return the formatted message.’, :type => :proc, :hidden => true.
Methods included from Definition
#[], #[]=, #accept_visitor, #action?, #child_by_name, #find, #get_value, included, #instantiate_children, #load, #long_opt, #name_array, #root, #separator?, #short_opt, #to_hash
Instance Attribute Details
#formatter ⇒ Object
formatterにはprocしか設定できないので特別設定ファイルやコマンドラインオプションで指定することはできません。 もしformatteを指す名前を指定したい場合は、別途定義したfieldをから求めたformatterの値を、 オーバーライドしたnew_loggerで設定するようにしてください。
45 46 47 |
# File 'lib/tengine/support/config/logger.rb', line 45 def formatter @formatter end |
Instance Method Details
#new_logger(options = {}) ⇒ Object
field :formatter, ‘Logging formatter, as a Proc that will take four arguments and return the formatted message.’,
:type => :proc, :hidden => true
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/tengine/support/config/logger.rb', line 49 def new_logger( = {}) = ActiveSupport::HashWithIndifferentAccess.new(to_hash).update( || {}) case output = [:output] when "NULL" then return Tengine::Support::NullLogger.new when "STDOUT" then dev = STDOUT when "STDERR" then dev = STDERR else dev = output end rotation = [:rotation] shift_age = (rotation =~ /\A\d+\Z/) ? rotation.to_i : rotation dtf = [:datetime_format] result = ::Logger.new(dev, shift_age, [:rotation_size]) result.formatter = ([:formatter] || dtf) ? Logger::Formatter.new : nil result.datetime_format = dtf if dtf result.level = ::Logger.const_get([:level].to_s.upcase) progname = [:progname] result.progname = progname if progname result end |