Class: UzuUzu::Logger::Stdout
- Defined in:
- lib/uzuuzu-core/logger/stdout.rb
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
Instance Method Summary collapse
-
#initialize(env = nil) ⇒ Stdout
constructor
A new instance of Stdout.
- #method_missing(action, *args) ⇒ Object
Constructor Details
#initialize(env = nil) ⇒ Stdout
Returns a new instance of Stdout.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/uzuuzu-core/logger/stdout.rb', line 12 def initialize(env=nil) @adapter = :stdout @logger = ::Logger.new($stdout) level = env['level'] || :debug case(level.to_sym) when :info @logger.level = ::Logger::Severity::INFO when :warn @logger.level = ::Logger::Severity::WARN when :error @logger.level = ::Logger::Severity::ERROR when :fatal @logger.level = ::Logger::Severity::FATAL when :unknown @logger.level = ::Logger::Severity::UNKNOWN else @logger.level = ::Logger::Severity::DEBUG end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(action, *args) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/uzuuzu-core/logger/stdout.rb', line 34 def method_missing(action, *args) 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 |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
8 9 10 |
# File 'lib/uzuuzu-core/logger/stdout.rb', line 8 def adapter @adapter end |