Class: Amazon::Coral::WrappedLogger
- Defined in:
- lib/amazon/coral/simplelog.rb
Overview
Wraps Ruby’s built in Logger to prepend a context string to log messages. This is useful to prefix log messages with the name of the originating class, etc.
Instance Method Summary collapse
- #debug(s) ⇒ Object
- #debug? ⇒ Boolean
- #error(s) ⇒ Object
- #error? ⇒ Boolean
- #fatal(s) ⇒ Object
- #fatal? ⇒ Boolean
- #format(s) ⇒ Object
- #info(s) ⇒ Object
- #info? ⇒ Boolean
-
#initialize(key, logger) ⇒ WrappedLogger
constructor
A new instance of WrappedLogger.
- #warn(s) ⇒ Object
- #warn? ⇒ Boolean
Constructor Details
#initialize(key, logger) ⇒ WrappedLogger
Returns a new instance of WrappedLogger.
13 14 15 16 |
# File 'lib/amazon/coral/simplelog.rb', line 13 def initialize(key, logger) @key = key @logger = logger end |
Instance Method Details
#debug(s) ⇒ Object
18 19 20 |
# File 'lib/amazon/coral/simplelog.rb', line 18 def debug(s) @logger.debug(format(s)) end |
#debug? ⇒ Boolean
34 35 36 |
# File 'lib/amazon/coral/simplelog.rb', line 34 def debug? @logger.debug? end |
#error(s) ⇒ Object
27 28 29 |
# File 'lib/amazon/coral/simplelog.rb', line 27 def error(s) @logger.error(format(s)) end |
#error? ⇒ Boolean
43 44 45 |
# File 'lib/amazon/coral/simplelog.rb', line 43 def error? @logger.error? end |
#fatal(s) ⇒ Object
30 31 32 |
# File 'lib/amazon/coral/simplelog.rb', line 30 def fatal(s) @logger.fatal(format(s)) end |
#fatal? ⇒ Boolean
46 47 48 |
# File 'lib/amazon/coral/simplelog.rb', line 46 def fatal? @logger.fatal? end |
#format(s) ⇒ Object
50 51 52 |
# File 'lib/amazon/coral/simplelog.rb', line 50 def format(s) return "#{@key}: #{s}" end |
#info(s) ⇒ Object
21 22 23 |
# File 'lib/amazon/coral/simplelog.rb', line 21 def info(s) @logger.info(format(s)) end |
#info? ⇒ Boolean
37 38 39 |
# File 'lib/amazon/coral/simplelog.rb', line 37 def info? @logger.info? end |
#warn(s) ⇒ Object
24 25 26 |
# File 'lib/amazon/coral/simplelog.rb', line 24 def warn(s) @logger.warn(format(s)) end |
#warn? ⇒ Boolean
40 41 42 |
# File 'lib/amazon/coral/simplelog.rb', line 40 def warn? @logger.warn? end |