Sha256: 8b50e4ffe66b147bd326f825d7a15587998a92b869999fea932d607c2b039f43

Contents?: true

Size: 633 Bytes

Versions: 10

Compression:

Stored size: 633 Bytes

Contents

# frozen_string_literal: true

# @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.
class StatsD::Instrument::LogSink
  attr_reader :logger, :severity

  def initialize(logger, severity: Logger::DEBUG)
    @logger = logger
    @severity = severity
  end

  def sample?(_sample_rate)
    true
  end

  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
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
statsd-instrument-3.0.0 lib/statsd/instrument/log_sink.rb
statsd-instrument-3.0.0.pre2 lib/statsd/instrument/log_sink.rb
statsd-instrument-2.9.2 lib/statsd/instrument/log_sink.rb
statsd-instrument-3.0.0.pre1 lib/statsd/instrument/log_sink.rb
statsd-instrument-2.9.1 lib/statsd/instrument/log_sink.rb
statsd-instrument-2.9.0 lib/statsd/instrument/log_sink.rb
statsd-instrument-2.8.0 lib/statsd/instrument/log_sink.rb
statsd-instrument-2.7.1 lib/statsd/instrument/log_sink.rb
statsd-instrument-2.7.0 lib/statsd/instrument/log_sink.rb
statsd-instrument-2.6.0 lib/statsd/instrument/log_sink.rb