Class: Camayoc::Handlers::Logger
- Inherits:
-
Object
- Object
- Camayoc::Handlers::Logger
- Defined in:
- lib/camayoc/handlers/logger.rb
Overview
Write stats to a logger. Specify the method to call on the logger instance with :method (usually something like :info). If not :method is specified :debug will be called on the logger. You can control the format of the message passed to the logger method using the :formatter Proc.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#formatter ⇒ Object
Returns the value of attribute formatter.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#method ⇒ Object
Returns the value of attribute method.
Instance Method Summary collapse
- #count(event) ⇒ Object
- #default_formatter ⇒ Object
-
#initialize(logger, options = {}) ⇒ Logger
constructor
A new instance of Logger.
- #timing(event) ⇒ Object
Constructor Details
#initialize(logger, options = {}) ⇒ Logger
Returns a new instance of Logger.
12 13 14 15 16 |
# File 'lib/camayoc/handlers/logger.rb', line 12 def initialize(logger, ={}) self.logger = logger self.method = [:method] self.formatter = ([:formatter] || default_formatter) end |
Instance Attribute Details
#formatter ⇒ Object
Returns the value of attribute formatter.
10 11 12 |
# File 'lib/camayoc/handlers/logger.rb', line 10 def formatter @formatter end |
#logger ⇒ Object
Returns the value of attribute logger.
10 11 12 |
# File 'lib/camayoc/handlers/logger.rb', line 10 def logger @logger end |
#method ⇒ Object
Returns the value of attribute method.
10 11 12 |
# File 'lib/camayoc/handlers/logger.rb', line 10 def method @method end |
Instance Method Details
#count(event) ⇒ Object
18 19 20 |
# File 'lib/camayoc/handlers/logger.rb', line 18 def count(event) write(:count,event) end |
#default_formatter ⇒ Object
26 27 28 29 30 |
# File 'lib/camayoc/handlers/logger.rb', line 26 def default_formatter Proc.new do |type,event| "#{type} #{event.ns_stat} #{event.value} #{Time.now.utc.to_i}" end end |
#timing(event) ⇒ Object
22 23 24 |
# File 'lib/camayoc/handlers/logger.rb', line 22 def timing(event) write(:timing,event) end |