Class: Camo::Logger

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

Constant Summary collapse

LOG_LEVELS =
["debug", "info", "error", "fatal"].freeze
LOG_LEVEL =
(LOG_LEVELS.find { |level| level == ENV["CAMORB_LOG_LEVEL"] } || "info").freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(outpipe, errpipe) ⇒ Logger

Returns a new instance of Logger.



8
9
10
11
# File 'lib/camo/logger.rb', line 8

def initialize(outpipe, errpipe)
  @outpipe = outpipe
  @errpipe = errpipe
end

Instance Attribute Details

#errpipeObject (readonly)

Returns the value of attribute errpipe.



3
4
5
# File 'lib/camo/logger.rb', line 3

def errpipe
  @errpipe
end

#outpipeObject (readonly)

Returns the value of attribute outpipe.



3
4
5
# File 'lib/camo/logger.rb', line 3

def outpipe
  @outpipe
end

Class Method Details

.stdioObject



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

def self.stdio
  new $stdout, $stderr
end

Instance Method Details

#debug(msg, params = {}) ⇒ Object



17
18
19
# File 'lib/camo/logger.rb', line 17

def debug(msg, params = {})
  outpipe.puts(compile_output("debug", msg, params)) if debug?
end

#error(msg, params = {}) ⇒ Object



25
26
27
# File 'lib/camo/logger.rb', line 25

def error(msg, params = {})
  errpipe.puts(compile_output("error", msg, params)) if error?
end

#info(msg, params = {}) ⇒ Object



21
22
23
# File 'lib/camo/logger.rb', line 21

def info(msg, params = {})
  outpipe.puts(compile_output("info", msg, params)) if info?
end