Skip to content

Commit

Permalink
Drying up the ISO timestring with nanoseconds
Browse files Browse the repository at this point in the history
  • Loading branch information
paukul committed Nov 15, 2010
1 parent 27e759b commit aafe620
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
5 changes: 5 additions & 0 deletions lib/amqp_logging.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@


module AMQPLogging module AMQPLogging
autoload :MetricsAgent, 'amqp_logging/metrics_agent' 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 end


require 'logger' require 'logger'
Expand Down
3 changes: 1 addition & 2 deletions lib/amqp_logging/metrics_agent.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ def []=(fieldname, value)
end end


def add_logline(severity, message, progname, logger) def add_logline(severity, message, progname, logger)
t = Time.now timestring = AMQPLogging.iso_time_with_nanoseconds
timestring = t.strftime("%Y-%m-%dT%H:%M:%S.#{t.usec}")
logtype = @logger_types[logger] logtype = @logger_types[logger]
lines = @fields[:loglines][logtype] lines = @fields[:loglines][logtype]
if !@truncated_status[logtype] && lines.size < @max_lines_per_logger if !@truncated_status[logtype] && lines.size < @max_lines_per_logger
Expand Down
3 changes: 1 addition & 2 deletions lib/amqp_logging/metrics_agent/rails.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
class ActionController::Base class ActionController::Base
def log_processing_for_request_id_with_metrics_agent def log_processing_for_request_id_with_metrics_agent
logger.agent[:page] = "#{self.class.name}\##{action_name}" logger.agent[:page] = "#{self.class.name}\##{action_name}"
t = Time.now logger.agent[:started_at] = AMQPLogging.iso_time_with_nanoseconds
logger.agent[:started_at] = t.strftime("%Y-%m-%dT%H:%M:%S.#{t.usec}")
log_processing_for_request_id_without_metrics_agent log_processing_for_request_id_without_metrics_agent
end end
alias_method_chain :log_processing_for_request_id, :metrics_agent alias_method_chain :log_processing_for_request_id, :metrics_agent
Expand Down

0 comments on commit aafe620

Please sign in to comment.