Sha256: 279241d8a527454c9dabc2ad0206da743fec3bd4417ec3a43b7b93c183fa7409

Contents?: true

Size: 1.17 KB

Versions: 44

Compression:

Stored size: 1.17 KB

Contents

module Sapience
  module Formatters
    class Default < Base
      # Default text log format
      #  Generates logs of the form:
      #    2011-07-19 14:36:15.660235 D [1149:ScriptThreadProcess] Rails -- Hello World
      def call(log, _logger) # rubocop:disable AbcSize, PerceivedComplexity, CyclomaticComplexity
        # Date & time
        message = time_format.nil? ? "" : "#{format_time(log.time)} "

        # Log level and process info
        message << "#{log.level_to_s} [#{log.process_info}]"

        # Tags
        message << " " << log.tags.collect { |tag| "[#{tag}]" }.join(" ") if log.tags && (log.tags.size > 0)

        # Duration
        message << " (#{log.duration_human})" if log.duration

        # Class / app name
        message << " #{log.name}"

        # Log message
        message << " -- #{log.message}" if log.message

        # Payload
        if (payload = log.payload_to_s)
          message << " -- " << payload
        end

        # Exceptions
        if log.exception
          message << " -- Exception: #{log.exception.class}: #{log.exception.message}\n"
          message << log.backtrace_to_s
        end
        message
      end
    end
  end
end

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
sapience-2.4.0 lib/sapience/formatters/default.rb
sapience-2.3.5 lib/sapience/formatters/default.rb
sapience-2.3.4 lib/sapience/formatters/default.rb
sapience-2.3.3 lib/sapience/formatters/default.rb
sapience-2.2.3 lib/sapience/formatters/default.rb
sapience-2.2.1 lib/sapience/formatters/default.rb
sapience-2.2.0 lib/sapience/formatters/default.rb
sapience-2.1.0 lib/sapience/formatters/default.rb
sapience-2.0.5 lib/sapience/formatters/default.rb
sapience-2.0.4 lib/sapience/formatters/default.rb
sapience-2.0.3 lib/sapience/formatters/default.rb
sapience-2.0.2 lib/sapience/formatters/default.rb
sapience-2.0.1 lib/sapience/formatters/default.rb
sapience-2.0.0 lib/sapience/formatters/default.rb
sapience-1.0.15 lib/sapience/formatters/default.rb
sapience-1.0.14 lib/sapience/formatters/default.rb
sapience-1.0.13 lib/sapience/formatters/default.rb
sapience-1.0.12 lib/sapience/formatters/default.rb
sapience-1.0.11 lib/sapience/formatters/default.rb
sapience-1.0.10 lib/sapience/formatters/default.rb