Class: Hanami::Web::RackLogger::UniversalLogger Private
- Inherits:
-
Object
- Object
- Hanami::Web::RackLogger::UniversalLogger
- Defined in:
- lib/hanami/web/rack_logger.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
- #logger ⇒ Object readonly private
Class Method Summary collapse
- .call(logger) ⇒ Object (also: []) private
Instance Method Summary collapse
- #error(message = nil, **payload) ⇒ Object private
-
#info(message = nil, **payload) ⇒ Object
private
Logs the entry as JSON.
-
#initialize(logger) ⇒ UniversalLogger
constructor
private
A new instance of UniversalLogger.
- #tagged(&blk) ⇒ Object private
Constructor Details
#initialize(logger) ⇒ UniversalLogger
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of UniversalLogger.
92 93 94 |
# File 'lib/hanami/web/rack_logger.rb', line 92 def initialize(logger) @logger = logger end |
Instance Attribute Details
#logger ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
88 89 90 |
# File 'lib/hanami/web/rack_logger.rb', line 88 def logger @logger end |
Class Method Details
.call(logger) ⇒ Object Also known as: []
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
65 66 67 68 69 |
# File 'lib/hanami/web/rack_logger.rb', line 65 def call(logger) return logger if compatible_logger?(logger) new(logger) end |
Instance Method Details
#error(message = nil, **payload) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
118 119 120 121 |
# File 'lib/hanami/web/rack_logger.rb', line 118 def error( = nil, **payload) payload[:message] = if logger.info(JSON.fast_generate(payload)) end |
#info(message = nil, **payload) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Logs the entry as JSON.
This ensures a reasonable (and parseable) representation of our log payload structures for loggers that are configured to wholly replace Hanami’s default logger.
109 110 111 112 |
# File 'lib/hanami/web/rack_logger.rb', line 109 def info( = nil, **payload) payload[:message] = if logger.info(JSON.fast_generate(payload)) end |
#tagged(&blk) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
98 99 100 |
# File 'lib/hanami/web/rack_logger.rb', line 98 def tagged(*, &blk) blk.call end |