Class: AbideDataProcessor::Processor::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/abide-data-processor/logger.rb

Constant Summary collapse

LEVELS =
{error: 1, warning: 2, info: 3, debug: 4}

Instance Method Summary collapse

Constructor Details

#initialize(level = :info, out = STDOUT, err = STDERR) ⇒ Logger

Returns a new instance of Logger.



8
9
10
11
12
13
14
15
16
# File 'lib/abide-data-processor/logger.rb', line 8

def initialize(level = :info, out = STDOUT, err = STDERR)
  @level = LEVELS[level]
  if @level.nil?
    raise ArgumentError, "Unknown log level at #{level}"
  end

  @out = out
  @err = err
end

Instance Method Details

#debug(message) ⇒ Object



18
19
20
21
22
# File 'lib/abide-data-processor/logger.rb', line 18

def debug(message)
  if @level >= LEVELS[:debug]
    @out.puts(message)
  end
end

#err(message) ⇒ Object



36
37
38
39
40
# File 'lib/abide-data-processor/logger.rb', line 36

def err(message)
  if @level >= LEVELS[:error]
    @err.puts(message)
  end
end

#inform(message) ⇒ Object



24
25
26
27
28
# File 'lib/abide-data-processor/logger.rb', line 24

def inform(message)
  if @level >= LEVELS[:info]
    @out.puts(message)
  end
end

#warn(message) ⇒ Object



30
31
32
33
34
# File 'lib/abide-data-processor/logger.rb', line 30

def warn(message)
  if @level >= LEVELS[:warning]
    @out.puts(message)
  end
end