Class: InstStatsd::RequestLogger
- Inherits:
-
Object
- Object
- InstStatsd::RequestLogger
- Defined in:
- lib/inst_statsd/request_logger.rb
Instance Method Summary collapse
- #build_log_message(request_stat, header = nil) ⇒ Object
-
#initialize(logger) ⇒ RequestLogger
constructor
A new instance of RequestLogger.
- #log(request_stat, header = nil) ⇒ Object
Constructor Details
#initialize(logger) ⇒ RequestLogger
Returns a new instance of RequestLogger.
5 6 7 |
# File 'lib/inst_statsd/request_logger.rb', line 5 def initialize(logger) @logger = logger || InstStatsd::NullLogger.new end |
Instance Method Details
#build_log_message(request_stat, header = nil) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/inst_statsd/request_logger.rb', line 13 def (request_stat, header = nil) header ||= "STATSD" = "[#{header}]" request_stat.stats.each do |(name, value)| += " (#{name.to_s.tr(".", "_")}: #{format("%.2f", value)})" end request_stat.exclusive_stats&.each do |(name, value)| += " (exclusive_#{name.to_s.tr(".", "_")}: #{format("%.2f", value)})" end end |
#log(request_stat, header = nil) ⇒ Object
9 10 11 |
# File 'lib/inst_statsd/request_logger.rb', line 9 def log(request_stat, header = nil) @logger.info((request_stat, header)) end |