Class: Trema::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/trema/logger.rb

Overview

The default logger.

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Logger

Returns a new instance of Logger.


6
7
8
9
10
11
12
# File 'lib/trema/logger.rb', line 6

def initialize(name)
  @name = name
  @logger = {}.tap do |list|
    list[:file] = create_file_logger
    list[:stdout] = create_stdout_logger
  end
end

Instance Method Details

#debug(message) ⇒ Object


34
35
36
# File 'lib/trema/logger.rb', line 34

def debug(message)
  output :debug, message
end

#error(message) ⇒ Object


22
23
24
# File 'lib/trema/logger.rb', line 22

def error(message)
  output :error, message
end

#fatal(message) ⇒ Object


18
19
20
# File 'lib/trema/logger.rb', line 18

def fatal(message)
  output :fatal, message
end

#info(message) ⇒ Object


30
31
32
# File 'lib/trema/logger.rb', line 30

def info(message)
  output :info, message
end

#levelObject


42
43
44
# File 'lib/trema/logger.rb', line 42

def level
  @logger[:file].level
end

#level=(level) ⇒ Object


38
39
40
# File 'lib/trema/logger.rb', line 38

def level=(level)
  @logger.values.each { |each| each.__send__ :level=, level }
end

#unknown(message) ⇒ Object


14
15
16
# File 'lib/trema/logger.rb', line 14

def unknown(message)
  output :unknown, message
end

#warn(message) ⇒ Object


26
27
28
# File 'lib/trema/logger.rb', line 26

def warn(message)
  output :warn, message
end