Skip to content

Commit

Permalink
Dont log timestamp on Heroku, fixes sidekiq#2343
Browse files Browse the repository at this point in the history
  • Loading branch information
mperham committed Jun 10, 2015
1 parent 1f7d52e commit 607e63c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions Changes.md
Expand Up @@ -4,6 +4,7 @@ HEAD
- Set a `created_at` attribute when jobs are created, set `enqueued_at` only
when they go into a queue. Fixes invalid latency calculations with scheduled jobs.
[#2373, mrsimo]
- Don't log timestamp on Heroku [#2343]

3.3.4
-----------
Expand Down
8 changes: 7 additions & 1 deletion lib/sidekiq/logging.rb
Expand Up @@ -18,6 +18,12 @@ def context
end
end

class WithoutTimestamp < Pretty
def call(severity, time, program_name, message)
"#{::Process.pid} TID-#{Thread.current.object_id.to_s(36)}#{context} #{severity}: #{message}\n"
end
end

def self.with_context(msg)
Thread.current[:sidekiq_context] ||= []
Thread.current[:sidekiq_context] << msg
Expand All @@ -30,7 +36,7 @@ def self.initialize_logger(log_target = STDOUT)
oldlogger = defined?(@logger) ? @logger : nil
@logger = Logger.new(log_target)
@logger.level = Logger::INFO
@logger.formatter = Pretty.new
@logger.formatter = ENV['DYNO'] ? WithoutTimestamp.new : Pretty.new
oldlogger.close if oldlogger && !$TESTING # don't want to close testing's STDOUT logging
@logger
end
Expand Down

0 comments on commit 607e63c

Please sign in to comment.