Sha256: b217f1bd42cab3f74f007869fb28b5c05a56ecd6b2cc40a3359108b87573c0d4

Contents?: true

Size: 472 Bytes

Versions: 1

Compression:

Stored size: 472 Bytes

Contents

require "English"

module ThreadedLogging
  def call(severity, time, _progname, msg)
    time_string = time.strftime("%Y-%m-%dT%H:%M:%S.") << format("%06d", time.usec)
    thread_id = Digest::MD5.hexdigest([Thread.current.object_id, $PID].join)[0...8]

    metadata = "#{severity[0]} [#{time_string}] ##{thread_id}:"
    message = ""
    msg.lines.each { |line| message << "#{metadata} #{line}" }
    "#{message}\n"
  end
end

::Logger::Formatter.prepend(ThreadedLogging)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
threaded_logging-0.1.0 lib/threaded_logging.rb