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, &blk) ⇒ Object private
-
#info(message = nil, **payload, &blk) ⇒ 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, &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.
124 125 126 127 128 129 130 131 132 133 |
# File 'lib/hanami/web/rack_logger.rb', line 124 def error( = nil, **payload, &blk) logger.error do if blk JSON.generate(blk.call) else payload[:message] = if JSON.generate(payload) end end end |
#info(message = nil, **payload, &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.
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 113 114 115 116 117 118 |
# File 'lib/hanami/web/rack_logger.rb', line 109 def info( = nil, **payload, &blk) logger.info do if blk JSON.generate(blk.call) else payload[:message] = if JSON.generate(payload) end end 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 |