Class: Dokkit::Logging::Observer::Console

Inherits:
Object
  • Object
show all
Defined in:
lib/dokkit/logging/observers/console.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logger) ⇒ Console

Returns a new instance of Console.



25
26
27
28
# File 'lib/dokkit/logging/observers/console.rb', line 25

def initialize(logger)
  @logger = logger
  @logger.attach(self)
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



23
24
25
# File 'lib/dokkit/logging/observers/console.rb', line 23

def logger
  @logger
end

Class Method Details

.loggerObject



18
19
20
# File 'lib/dokkit/logging/observers/console.rb', line 18

def logger
  Console.new(Logger.new).logger
end

Instance Method Details

#updateObject



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/dokkit/logging/observers/console.rb', line 30

def update
  case last_message[:level]
  when Logging::ERROR
    fail "[#{Time.now.asctime}][ERROR] #{last_message[:text]}"
  when Logging::WARNING
    warn "[#{Time.now.asctime}][WARNING] #{last_message[:text]}"
  when Logging::INFO
    puts "[#{Time.now.asctime}][INFO] #{last_message[:text]}"
  when Logging::DEBUG
    puts "[#{Time.now.asctime}][DEBUG] #{last_message[:text]}"
  end
end