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.



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

#loggerObject (readonly)

Returns the value of attribute logger.



8
9
10
# File 'lib/statsd/instrument/log_sink.rb', line 8

def logger
  @logger
end

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

#sample?(_sample_rate) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/statsd/instrument/log_sink.rb', line 15

def sample?(_sample_rate)
  true
end