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.112.0 lib/semantic_logger/formatters/short.rb
pact_broker-2.111.0 lib/semantic_logger/formatters/short.rb
pact_broker-2.109.1 lib/semantic_logger/formatters/short.rb
pact_broker-2.109.0 lib/semantic_logger/formatters/short.rb
pact_broker-2.108.0 lib/semantic_logger/formatters/short.rb
pact_broker-2.107.1 lib/semantic_logger/formatters/short.rb
pact_broker-2.107.0 lib/semantic_logger/formatters/short.rb
pact_broker-2.107.0.beta.1 lib/semantic_logger/formatters/short.rb
pact_broker-2.106.0 lib/semantic_logger/formatters/short.rb
pact_broker-2.105.0 lib/semantic_logger/formatters/short.rb
pact_broker-2.104.0 lib/semantic_logger/formatters/short.rb
pact_broker-2.103.0 lib/semantic_logger/formatters/short.rb
pact_broker-2.102.2 lib/semantic_logger/formatters/short.rb
pact_broker-2.102.1 lib/semantic_logger/formatters/short.rb
pact_broker-2.102.0 lib/semantic_logger/formatters/short.rb
pact_broker-2.101.0 lib/semantic_logger/formatters/short.rb
pact_broker-2.100.0 lib/semantic_logger/formatters/short.rb
pact_broker-2.99.0 lib/semantic_logger/formatters/short.rb
pact_broker-2.98.0 lib/semantic_logger/formatters/short.rb
pact_broker-2.97.0 lib/semantic_logger/formatters/short.rb