Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Drying up the ISO timestring with nanoseconds

  • Loading branch information...
commit aafe620e2d468df7e4e1179eaf509a7330c71852 1 parent 27e759b
@paukul authored
View
5 lib/amqp_logging.rb
@@ -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'
View
3  lib/amqp_logging/metrics_agent.rb
@@ -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
View
3  lib/amqp_logging/metrics_agent/rails.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.