Class: StatsD::Instrument::LogSink
- Inherits:
-
Object
- Object
- StatsD::Instrument::LogSink
- Defined in:
- lib/statsd/instrument/log_sink.rb
Overview
Note:
This class is part of the new Client implementation that is intended to become the new default in the next major release of this library.
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#severity ⇒ Object
readonly
Returns the value of attribute severity.
Instance Method Summary collapse
- #<<(datagram) ⇒ Object
-
#initialize(logger, severity: Logger::DEBUG) ⇒ LogSink
constructor
A new instance of LogSink.
- #sample?(_sample_rate) ⇒ Boolean
Constructor Details
#initialize(logger, severity: Logger::DEBUG) ⇒ LogSink
Returns a new instance of LogSink.
8 9 10 11 |
# File 'lib/statsd/instrument/log_sink.rb', line 8 def initialize(logger, severity: Logger::DEBUG) @logger = logger @severity = severity end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
6 7 8 |
# File 'lib/statsd/instrument/log_sink.rb', line 6 def logger @logger end |
#severity ⇒ Object (readonly)
Returns the value of attribute severity.
6 7 8 |
# File 'lib/statsd/instrument/log_sink.rb', line 6 def severity @severity end |
Instance Method Details
#<<(datagram) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/statsd/instrument/log_sink.rb', line 17 def <<(datagram) # Some implementations require a newline at the end of datagrams. # When logging, we make sure those newlines are removed using chomp. logger.add(severity, "[StatsD] #{datagram.chomp}") self end |
#sample?(_sample_rate) ⇒ Boolean
13 14 15 |
# File 'lib/statsd/instrument/log_sink.rb', line 13 def sample?(_sample_rate) true end |