Sha256: 2909d94e2d01766d160f406f1c9807e6dccb2abc2aa3a2fb4fb52b87d4730430
Contents?: true
Size: 1.13 KB
Versions: 3
Compression:
Stored size: 1.13 KB
Contents
# frozen_string_literal: true module MrLogaLoga module Formatters # == Description # # A simple key value formatter that extends the standard formatter by rendering additional contextual information. # # == Format # # The key-value formatter renders messages into the following format: # # Log format: # # SeverityID, [DateTime #pid] SeverityLabel -- ProgName: message key1=value1 key2=value2 # class KeyValue < Logger::Formatter # Render a log message # # @param severity [String] The message severity # @param datetime [DateTime] The message date time # @param progname [DateTime] The program name # @param message [String] The log message # @param context [Hash] The log message context # # @return [String] the formatted log message def call(severity, datetime, progname, message, **context) message = context.map { |key, value| "#{key}=#{value}" } .prepend(message) .compact .join(' ') super(severity, datetime, progname, message) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
mr_loga_loga-0.1.3 | lib/mr_loga_loga/formatters/key_value.rb |
mr_loga_loga-0.1.2 | lib/mr_loga_loga/formatters/key_value.rb |
mr_loga_loga-0.1.1 | lib/mr_loga_loga/formatters/key_value.rb |