Sha256: 0d6966049f55ee3a461f3ff629c85db68208909ffb32b4fdb29debf20fa47fb3

Contents?: true

Size: 601 Bytes

Versions: 1

Compression:

Stored size: 601 Bytes

Contents

module ClearLogic
  module Logger
    class Default < ::Logger
      DATE_FORMAT = '%y-%m-%d %H:%M:%S.%3N '.freeze
      FORMAT = "[%s#%d#%d] %5s -- %s: %s\n".freeze

      def format_message(severity, time, progname, context)
        thread_id = Thread.current.object_id % 100_000

        format(FORMAT, format_datetime(time), Process.pid, thread_id, severity, progname, pretty_view(context))
      end

      private

      def format_datetime(time)
        time.strftime(DATE_FORMAT)
      end

      def pretty_view(context)
        JSON.pretty_generate(context.to_h)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
clear_logic-0.1.1 lib/clear_logic/logger/default.rb