Skip to content

Commit

Permalink
[api] add a timestamp in front of the log message
Browse files Browse the repository at this point in the history
(at least while I'm hunting slow routes :)
  • Loading branch information
coolo committed Jul 25, 2013
1 parent 109d6ff commit 7e95814
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/api/config/initializers/logging.rb
Expand Up @@ -25,7 +25,16 @@ def log_process_action(payload)
end
end

module TimestampFormatter
def call(severity, timestamp, progname, msg)
Thread.current[:timestamp_formatter_timestamp] ||= Time.now
tdiff = sprintf("%02.2f", Time.now - Thread.current[:timestamp_formatter_timestamp])
super(severity, timestamp, progname, "[#{tdiff}] #{msg}")
end
end

ActiveSupport.on_load(:action_controller) do
include APIInstrumentation::ControllerRuntime
Rails.logger.formatter.extend(TimestampFormatter)
end

0 comments on commit 7e95814

Please sign in to comment.