Module: Consul::Template::Generator::STDLogger

Defined in:
lib/consul/template/generator/configuration.rb

Class Method Summary collapse

Class Method Details

.debug(msg) ⇒ Object



21
22
23
24
25
# File 'lib/consul/template/generator/configuration.rb', line 21

def debug(msg)
  if do_log?(:debug, Consul::Template::Generator.config.log_level)
    STDOUT.puts "[DEBUG] #{msg}"
  end
end

.do_log?(requested_lvl, curr_lvl) ⇒ Boolean



15
16
17
18
19
# File 'lib/consul/template/generator/configuration.rb', line 15

def do_log?(requested_lvl, curr_lvl)
  curr_lvl = Consul::Template::Generator::STDLogLvl.send(curr_lvl.to_sym)
  requested_lvl = Consul::Template::Generator::STDLogLvl.send(requested_lvl.to_sym)
  requested_lvl >= curr_lvl
end

.error(msg) ⇒ Object



33
34
35
36
37
# File 'lib/consul/template/generator/configuration.rb', line 33

def error(msg)
  if do_log?(:error, Consul::Template::Generator.config.log_level)
    STDERR.puts "[ERROR] #{msg}"
  end
end

.info(msg) ⇒ Object



27
28
29
30
31
# File 'lib/consul/template/generator/configuration.rb', line 27

def info(msg)
  if do_log?(:info, Consul::Template::Generator.config.log_level)
    STDOUT.puts "[INFO] #{msg}"
  end
end