Sha256: be61a76484fa712ad378ed1163bb6ad55839faf533b0355f5ac88faca0e410d3

Contents?: true

Size: 782 Bytes

Versions: 12

Compression:

Stored size: 782 Bytes

Contents

# frozen_string_literal: true

module StatsD
  module Instrument
    # @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 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

      def flush(blocking:)
        # noop
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
statsd-instrument-3.9.9 lib/statsd/instrument/log_sink.rb
statsd-instrument-3.9.8 lib/statsd/instrument/log_sink.rb
statsd-instrument-3.9.7 lib/statsd/instrument/log_sink.rb
statsd-instrument-3.9.6 lib/statsd/instrument/log_sink.rb
statsd-instrument-3.9.5 lib/statsd/instrument/log_sink.rb
statsd-instrument-3.9.4 lib/statsd/instrument/log_sink.rb
statsd-instrument-3.9.3 lib/statsd/instrument/log_sink.rb
statsd-instrument-3.9.2 lib/statsd/instrument/log_sink.rb
statsd-instrument-3.9.1 lib/statsd/instrument/log_sink.rb
statsd-instrument-3.9.0 lib/statsd/instrument/log_sink.rb
statsd-instrument-3.8.0 lib/statsd/instrument/log_sink.rb
statsd-instrument-3.7.0 lib/statsd/instrument/log_sink.rb