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
- #flush(blocking:) ⇒ 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.
10 11 12 13 |
# File 'lib/statsd/instrument/log_sink.rb', line 10 def initialize(logger, severity: Logger::DEBUG) @logger = logger @severity = severity end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
8 9 10 |
# File 'lib/statsd/instrument/log_sink.rb', line 8 def logger @logger end |
#severity ⇒ Object (readonly)
Returns the value of attribute severity.
8 9 10 |
# File 'lib/statsd/instrument/log_sink.rb', line 8 def severity @severity end |
Instance Method Details
#<<(datagram) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/statsd/instrument/log_sink.rb', line 19 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 |
#flush(blocking:) ⇒ Object
27 28 29 |
# File 'lib/statsd/instrument/log_sink.rb', line 27 def flush(blocking:) # noop end |
#sample?(_sample_rate) ⇒ Boolean
15 16 17 |
# File 'lib/statsd/instrument/log_sink.rb', line 15 def sample?(_sample_rate) true end |