Class: UzuUzu::Logger::Loggers
- Defined in:
- lib/uzuuzu-core/logger/loggers.rb
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
Instance Method Summary collapse
-
#initialize(env = nil) ⇒ Loggers
constructor
A new instance of Loggers.
- #method_missing(action, *args) ⇒ Object
Constructor Details
#initialize(env = nil) ⇒ Loggers
Returns a new instance of Loggers.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/uzuuzu-core/logger/loggers.rb', line 11 def initialize(env=nil) @adapter = :loggers @loggers = [] unless env return end env.each do |logger_env| adapter = logger_env["adapter"] require "uzuuzu-core/logger/#{adapter}" adapter_class = eval("::UzuUzu::Logger::#{adapter.camel_case}") logger = adapter_class.new(logger_env) @loggers << logger end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(action, *args) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/uzuuzu-core/logger/loggers.rb', line 28 def method_missing(action, *args) @loggers.each do |logger| begin args.each do || = .to_str if .respond_to?(:to_str) = .inspect unless .instance_of?(String) logger.send(action, ) end rescue => e # puts standerd error output $stderr.puts 'logger unknown error' $stderr.puts e end end end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
7 8 9 |
# File 'lib/uzuuzu-core/logger/loggers.rb', line 7 def adapter @adapter end |