Class: Camping::Firewatch
- Defined in:
- lib/gear/firewatch.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(app, logger = nil) ⇒ Firewatch
constructor
logger
can be any object that supports thewrite
or << methods, which includes the standard library Logger.
Constructor Details
#initialize(app, logger = nil) ⇒ Firewatch
logger
can be any object that supports the write
or << methods, which includes the standard library Logger. These methods are called with a single string argument, the log message. If logger
is nil, Firewatch(CommonLogger) will fall back env['rack.errors']
.
31 32 33 34 35 36 37 38 39 |
# File 'lib/gear/firewatch.rb', line 31 def initialize(app, logger = nil) @app = app if logger == nil @logger = Camping::Firewatch.default_logger else @logger = logger end # @logger = Camping::Firewatch.logger = logger.nil? ? Camping::Firewatch.default_logger : logger end |
Class Method Details
.default_logger ⇒ Object
19 20 21 |
# File 'lib/gear/firewatch.rb', line 19 def default_logger Dry.Logger(:Camping, template: default_template).add_backend(stream: "logs/development.log") end |
.default_template ⇒ Object
22 23 24 |
# File 'lib/gear/firewatch.rb', line 22 def default_template "[<green>%<severity>s</green> - %<time>s] %<message>s" end |
.logger ⇒ Object
13 14 15 |
# File 'lib/gear/firewatch.rb', line 13 def logger @logger ||= default_logger end |
.logger=(new_logger) ⇒ Object
16 17 18 |
# File 'lib/gear/firewatch.rb', line 16 def logger=(new_logger) @logger = new_logger end |