lib/service_skeleton/config.rb in service_skeleton-0.0.0.29.g23642ab vs lib/service_skeleton/config.rb in service_skeleton-0.0.0.30.g32b8169

- old
+ new

@@ -60,13 +60,23 @@ loggerstash = Loggerstash.new(logstash_server: logstash_server, logger: @logger) loggerstash.metrics_registry = @svc.metrics loggerstash.attach(@logger) end - if log_enable_timestamps - @logger.formatter = ->(s, t, p, m) { "#{t.utc.strftime("%FT%T.%NZ")} #{s[0]} [#{p}] #{m}\n" } + thread_id_map = {} + if Thread.main + thread_id_map[Thread.main.object_id] = 0 else - @logger.formatter = ->(s, t, p, m) { "#{s[0]} [#{p}] #{m}\n" } + #:nocov: + thread_id_map[Thread.current.object_id] = 0 + #:nocov: + end + + @logger.formatter = ->(s, t, p, m) do + th_n = thread_id_map[Thread.current.object_id] || (thread_id_map[Thread.current.object_id] = thread_id_map.length) + + ts = log_enable_timestamps ? "#{t.utc.strftime("%FT%T.%NZ")} " : "" + "#{ts}##{th_n} #{s[0]} [#{p}] #{m}\n" end @logger.filters = [] @env.fetch("#{@svc.service_name.upcase}_LOG_LEVEL", "INFO").split(/\s*,\s*/).each do |spec| if spec.index("=")