Class: SemanticLogger::Formatters::Loki
- Defined in:
- lib/semantic_logger/formatters/loki.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
-
#payload_value ⇒ Object
Returns the value of attribute payload_value.
-
#stream ⇒ Object
Returns the value of attribute stream.
Attributes inherited from Base
#log, #log_application, #log_environment, #log_host, #logger, #precision, #time_format
Instance Method Summary collapse
-
#batch(logs, logger) ⇒ Object
Returns [String] a JSON batch of logs.
-
#call(log, logger) ⇒ Object
Returns [String] a single JSON log.
Methods inherited from Base
build_time_format, #initialize, #pid
Constructor Details
This class inherits a constructor from SemanticLogger::Formatters::Base
Instance Attribute Details
#payload_value ⇒ Object
Returns the value of attribute payload_value.
6 7 8 |
# File 'lib/semantic_logger/formatters/loki.rb', line 6 def payload_value @payload_value end |
#stream ⇒ Object
Returns the value of attribute stream.
6 7 8 |
# File 'lib/semantic_logger/formatters/loki.rb', line 6 def stream @stream end |
Instance Method Details
#batch(logs, logger) ⇒ Object
Returns [String] a JSON batch of logs
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/semantic_logger/formatters/loki.rb', line 17 def batch(logs, logger) self.logger = logger streams = logs.map do |log| self.log = log build_stream end {streams: streams}.to_json end |
#call(log, logger) ⇒ Object
Returns [String] a single JSON log
9 10 11 12 13 14 |
# File 'lib/semantic_logger/formatters/loki.rb', line 9 def call(log, logger) self.logger = logger self.log = log {streams: [build_stream]}.to_json end |