Sha256: 58b2f0fe7b190acf7834531423d94768e66e810f159d8236fdb9dd01b377fb00

Contents?: true

Size: 800 Bytes

Versions: 42

Compression:

Stored size: 800 Bytes

Contents

require "semantic_logger/formatters/default"

module SemanticLogger
  module Formatters
    class Short < SemanticLogger::Formatters::Default
      TAGS_TO_REMOVE = [:pact_broker_git_sha, :tenant_id, :request_id, :pactflow_git_sha]

      def call(log, logger)
        self.log    = log
        self.logger = logger

        [time, level, tags, named_tags, duration, message, payload, exception].compact.join(" ")
      end

      def time
        log.time.strftime("%H:%M:%S")
      end

      def named_tags
        named_tags = log.named_tags.reject{ | k, _ | TAGS_TO_REMOVE.include?(k) }
        return if named_tags.nil? || named_tags.empty?

        list = []
        named_tags.each_pair { |name, value| list << "#{name}: #{value}" }
        "{#{list.join(', ')}}"
      end
    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
pact_broker-2.96.0 lib/semantic_logger/formatters/short.rb
pact_broker-2.95.1 lib/semantic_logger/formatters/short.rb
pact_broker-2.95.0 lib/semantic_logger/formatters/short.rb
pact_broker-2.94.0 lib/semantic_logger/formatters/short.rb
pact_broker-2.93.4 lib/semantic_logger/formatters/short.rb
pact_broker-2.93.3 lib/semantic_logger/formatters/short.rb
pact_broker-2.93.2 lib/semantic_logger/formatters/short.rb
pact_broker-2.93.1 lib/semantic_logger/formatters/short.rb
pact_broker-2.93.0 lib/semantic_logger/formatters/short.rb
pact_broker-2.92.0 lib/semantic_logger/formatters/short.rb
pact_broker-2.91.0 lib/semantic_logger/formatters/short.rb
pact_broker-2.90.0 lib/semantic_logger/formatters/short.rb
pact_broker-2.89.1 lib/semantic_logger/formatters/short.rb
pact_broker-2.89.0 lib/semantic_logger/formatters/short.rb
pact_broker-2.88.0 lib/semantic_logger/formatters/short.rb
pact_broker-2.87.0 lib/semantic_logger/formatters/short.rb
pact_broker-2.86.0 lib/semantic_logger/formatters/short.rb
pact_broker-2.85.1 lib/semantic_logger/formatters/short.rb
pact_broker-2.85.0 lib/semantic_logger/formatters/short.rb
pact_broker-2.84.0 lib/semantic_logger/formatters/short.rb