Sha256: eb2de3cae5b173e67c9dd5efa0393783f2317604349228b50db2e833440df70f

Contents?: true

Size: 729 Bytes

Versions: 24

Compression:

Stored size: 729 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
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
statsd-instrument-3.6.1 lib/statsd/instrument/log_sink.rb
statsd-instrument-3.6.0 lib/statsd/instrument/log_sink.rb
statsd-instrument-3.5.12 lib/statsd/instrument/log_sink.rb
statsd-instrument-3.5.11 lib/statsd/instrument/log_sink.rb
statsd-instrument-3.5.10 lib/statsd/instrument/log_sink.rb
statsd-instrument-3.5.9 lib/statsd/instrument/log_sink.rb
statsd-instrument-3.5.8 lib/statsd/instrument/log_sink.rb
statsd-instrument-3.5.7 lib/statsd/instrument/log_sink.rb
statsd-instrument-3.5.6 lib/statsd/instrument/log_sink.rb
statsd-instrument-3.5.5 lib/statsd/instrument/log_sink.rb
statsd-instrument-3.5.4 lib/statsd/instrument/log_sink.rb
statsd-instrument-3.5.3 lib/statsd/instrument/log_sink.rb
statsd-instrument-3.5.2 lib/statsd/instrument/log_sink.rb
statsd-instrument-3.5.1 lib/statsd/instrument/log_sink.rb
statsd-instrument-3.5.0 lib/statsd/instrument/log_sink.rb
statsd-instrument-3.4.0 lib/statsd/instrument/log_sink.rb
statsd-instrument-3.3.0 lib/statsd/instrument/log_sink.rb
statsd-instrument-3.2.1 lib/statsd/instrument/log_sink.rb
statsd-instrument-3.2.0 lib/statsd/instrument/log_sink.rb
statsd-instrument-3.1.2 lib/statsd/instrument/log_sink.rb