Class: Purview::Loggers::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/purview/loggers/base.rb

Direct Known Subclasses

Console

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Base

Returns a new instance of Base.



4
5
6
# File 'lib/purview/loggers/base.rb', line 4

def initialize(opts={})
  @opts = default_opts.merge(opts)
end

Instance Method Details

#debug(*args) ⇒ Object



8
9
10
# File 'lib/purview/loggers/base.rb', line 8

def debug(*args)
  log(DEBUG_LEVEL, *args) if debug?
end

#error(*args) ⇒ Object



12
13
14
# File 'lib/purview/loggers/base.rb', line 12

def error(*args)
  log(ERROR_LEVEL, *args) if error?
end

#info(*args) ⇒ Object



16
17
18
# File 'lib/purview/loggers/base.rb', line 16

def info(*args)
  log(INFO_LEVEL, *args) if info?
end

#with_context_logging(*args) ⇒ Object



20
21
22
23
# File 'lib/purview/loggers/base.rb', line 20

def with_context_logging(*args)
  debug(build_starting_message(*args))
  yield.tap { |result| debug(build_finished_message(*args)) }
end