Module: Chronicle::ETL::Logger

Extended by:
Logger
Included in:
Logger
Defined in:
lib/chronicle/etl/logger.rb

Constant Summary collapse

DEBUG =
0
INFO =
1
WARN =
2
ERROR =
3
FATAL =
4
SILENT =
5

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#log_levelObject

Returns the value of attribute log_level.



13
14
15
# File 'lib/chronicle/etl/logger.rb', line 13

def log_level
  @log_level
end

Instance Method Details

#attach_to_ui(ui_element) ⇒ Object



43
44
45
# File 'lib/chronicle/etl/logger.rb', line 43

def attach_to_ui(ui_element)
  @ui_element = ui_element
end

#debug(message) ⇒ Object



39
40
41
# File 'lib/chronicle/etl/logger.rb', line 39

def debug(message)
  output(message, DEBUG)
end

#detach_from_uiObject



47
48
49
# File 'lib/chronicle/etl/logger.rb', line 47

def detach_from_ui
  @ui_element = nil
end

#error(message) ⇒ Object



31
32
33
# File 'lib/chronicle/etl/logger.rb', line 31

def error(message)
  output(message, ERROR)
end

#fatal(message) ⇒ Object



27
28
29
# File 'lib/chronicle/etl/logger.rb', line 27

def fatal(message)
  output(message, FATAL)
end

#info(message) ⇒ Object



35
36
37
# File 'lib/chronicle/etl/logger.rb', line 35

def info(message)
  output(message, INFO)
end

#output(message, level) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/chronicle/etl/logger.rb', line 17

def output(message, level)
  return unless level >= @log_level

  if @ui_element
    @ui_element.log(message)
  else
    warn(message)
  end
end