Class: UzuUzu::Logger::Appengine

Inherits:
Object
  • Object
show all
Defined in:
lib/uzuuzu-core/logger/appengine.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env = nil) ⇒ Appengine

Returns a new instance of Appengine.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/uzuuzu-core/logger/appengine.rb', line 13

def initialize(env=nil)
  @adapter = :appengine
  @logger = AppEngine::Logger.new
  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



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/uzuuzu-core/logger/appengine.rb', line 35

def method_missing(action, *args)
  begin
    args.each do |message|
      message = message.to_str if message.respond_to?(:to_str)
      message = message.inspect unless message.instance_of?(String)
      @logger.send(action, message)
    end
  rescue => e
    # puts standerd error output
    $stderr.puts 'logger unknown error'
    $stderr.puts e
  end
end

Instance Attribute Details

#adapterObject (readonly)

Returns the value of attribute adapter.



9
10
11
# File 'lib/uzuuzu-core/logger/appengine.rb', line 9

def adapter
  @adapter
end