Class: TileUp::TileUpLogger
- Inherits:
-
Object
- Object
- TileUp::TileUpLogger
- Defined in:
- lib/tileup/logger.rb
Overview
Base logger class, subclass this, do not use directly.
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
-
#error(message) ⇒ Object
log an error message.
-
#info(message) ⇒ Object
log a regular message.
-
#initialize(level, options) ⇒ TileUpLogger
constructor
create logger set to given level where level is a symbol (:debug, :info, :warn, :error, :fatal) options may specifiy verbose, which will log more info messages.
- #level ⇒ Object
- #level=(severity) ⇒ Object
-
#verbose(message) ⇒ Object
log a verbose message.
- #warn(message) ⇒ Object
Constructor Details
#initialize(level, options) ⇒ TileUpLogger
create logger set to given level where level is a symbol (:debug, :info, :warn, :error, :fatal) options may specifiy verbose, which will log more info messages
23 24 25 26 27 28 29 |
# File 'lib/tileup/logger.rb', line 23 def initialize(level, ) @severity = level = { verbose: false } @options = OpenStruct.new(.merge()) end |
Class Method Details
.sym_to_severity(sym) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/tileup/logger.rb', line 9 def self.sym_to_severity(sym) severities = { :debug => Logger::DEBUG, :info => Logger::INFO, :warn => Logger::WARN, :error => Logger::ERROR, :fatal => Logger::FATAL } severity = severities[sym] || Logger::UNKNOWN end |
Instance Method Details
#error(message) ⇒ Object
log an error message
40 41 42 43 |
# File 'lib/tileup/logger.rb', line 40 def error() # note, we always log error messages add(:error, ) end |
#info(message) ⇒ Object
log a regular message
46 47 48 |
# File 'lib/tileup/logger.rb', line 46 def info() add(:info, ) end |
#level ⇒ Object
31 32 33 |
# File 'lib/tileup/logger.rb', line 31 def level @level end |
#level=(severity) ⇒ Object
35 36 37 |
# File 'lib/tileup/logger.rb', line 35 def level=(severity) logger.level = TileUpLogger.sym_to_severity(severity) end |
#verbose(message) ⇒ Object
log a verbose message
55 56 57 |
# File 'lib/tileup/logger.rb', line 55 def verbose() add(:info, ) if verbose? end |
#warn(message) ⇒ Object
50 51 52 |
# File 'lib/tileup/logger.rb', line 50 def warn() add(:warn, ) end |