Permalink
Browse files

Drying up the ISO timestring with nanoseconds

  • Loading branch information...
1 parent 27e759b commit aafe620e2d468df7e4e1179eaf509a7330c71852 @paukul committed Nov 15, 2010
Showing with 7 additions and 4 deletions.
  1. +5 −0 lib/amqp_logging.rb
  2. +1 −2 lib/amqp_logging/metrics_agent.rb
  3. +1 −2 lib/amqp_logging/metrics_agent/rails.rb
View
@@ -10,6 +10,11 @@
module AMQPLogging
autoload :MetricsAgent, 'amqp_logging/metrics_agent'
+
+ private
+ def self.iso_time_with_nanoseconds(t = Time.now)
+ t.strftime("%Y-%m-%dT%H:%M:%S.#{t.usec}")
+ end
end
require 'logger'
@@ -44,8 +44,7 @@ def []=(fieldname, value)
end
def add_logline(severity, message, progname, logger)
- t = Time.now
- timestring = t.strftime("%Y-%m-%dT%H:%M:%S.#{t.usec}")
+ timestring = AMQPLogging.iso_time_with_nanoseconds
logtype = @logger_types[logger]
lines = @fields[:loglines][logtype]
if !@truncated_status[logtype] && lines.size < @max_lines_per_logger
@@ -8,8 +8,7 @@
class ActionController::Base
def log_processing_for_request_id_with_metrics_agent
logger.agent[:page] = "#{self.class.name}\##{action_name}"
- t = Time.now
- logger.agent[:started_at] = t.strftime("%Y-%m-%dT%H:%M:%S.#{t.usec}")
+ logger.agent[:started_at] = AMQPLogging.iso_time_with_nanoseconds
log_processing_for_request_id_without_metrics_agent
end
alias_method_chain :log_processing_for_request_id, :metrics_agent

0 comments on commit aafe620

Please sign in to comment.