lib/threaded_logging.rb in threaded_logging-0.1.2 vs lib/threaded_logging.rb in threaded_logging-0.2

- old
+ new

@@ -1,14 +1,19 @@ +# frozen_string_literal: true + +require "logger" require "English" module ThreadedLogging + def self.thread_fingerprint + Digest::MD5.hexdigest([Thread.current.object_id, $PID].join)[0...8] + end + def call(severity, time, _progname, msg) time_string = time.strftime("%Y-%m-%dT%H:%M:%S.%6N") - thread_id = Digest::MD5.hexdigest([Thread.current.object_id, $PID].join)[0...8] + metadata = "#{severity[0]} [#{time_string}] ##{ThreadedLogging.thread_fingerprint}:" - metadata = "#{severity[0]} [#{time_string}] ##{thread_id}:" - - message = "" + message = +"" msg.to_s.lines.each { |line| message << "#{metadata} #{line}" } "#{message}\n" end end