Module: ThreadedLogging

Defined in:
lib/threaded_logging.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.thread_fingerprintObject



8
9
10
# File 'lib/threaded_logging.rb', line 8

def self.thread_fingerprint
  Digest::MD5.hexdigest([Thread.current.object_id, $PID].join)[0...8]
end

Instance Method Details

#call(severity, time, _progname, msg) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/threaded_logging.rb', line 12

def call(severity, time, _progname, msg)
  time_string = time.strftime("%Y-%m-%dT%H:%M:%S.%6N")
   = "#{severity[0]} [#{time_string}] ##{ThreadedLogging.thread_fingerprint}:"

  message = +""
  msg.to_s.lines.each { |line| message << "#{} #{line}" }
  "#{message}\n"
end