Class: Herdsman::LogAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/herdsman/log_adapter.rb

Constant Summary collapse

LOG_LEVELS =
{
  debug: ::Logger::DEBUG,
  info:  ::Logger::INFO,
  warn:  ::Logger::WARN,
  error: ::Logger::ERROR,
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(writer) ⇒ LogAdapter

Returns a new instance of LogAdapter.



26
27
28
# File 'lib/herdsman/log_adapter.rb', line 26

def initialize(writer)
  @writer = writer
end

Instance Attribute Details

#writerObject

Returns the value of attribute writer.



3
4
5
# File 'lib/herdsman/log_adapter.rb', line 3

def writer
  @writer
end

Instance Method Details

#adjust_verbosity(options = {}) ⇒ Object



20
21
22
23
24
# File 'lib/herdsman/log_adapter.rb', line 20

def adjust_verbosity(options = {})
  if options[:quiet]
    self.log_level = :error
  end
end

#debug(message) ⇒ Object



30
31
32
# File 'lib/herdsman/log_adapter.rb', line 30

def debug(message)
  writer.debug(message)
end

#error(message) ⇒ Object



42
43
44
# File 'lib/herdsman/log_adapter.rb', line 42

def error(message)
  writer.error(message)
end

#info(message) ⇒ Object



34
35
36
# File 'lib/herdsman/log_adapter.rb', line 34

def info(message)
  writer.info(message)
end

#log_levelObject



12
13
14
# File 'lib/herdsman/log_adapter.rb', line 12

def log_level
  writer.level
end

#log_level=(level) ⇒ Object



16
17
18
# File 'lib/herdsman/log_adapter.rb', line 16

def log_level=(level)
  writer.level = LOG_LEVELS.fetch(level)
end

#warn(message) ⇒ Object



38
39
40
# File 'lib/herdsman/log_adapter.rb', line 38

def warn(message)
  writer.warn(message)
end