Class: StatsD::Instrument::LogSink

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#loggerObject (readonly)

Returns the value of attribute logger.



6
7
8
# File 'lib/statsd/instrument/log_sink.rb', line 6

def logger
  @logger
end

#severityObject (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

Returns:

  • (Boolean)


13
14
15
# File 'lib/statsd/instrument/log_sink.rb', line 13

def sample?(_sample_rate)
  true
end