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.1.1 lib/statsd/instrument/log_sink.rb
statsd-instrument-3.1.0 lib/statsd/instrument/log_sink.rb
statsd-instrument-3.0.2 lib/statsd/instrument/log_sink.rb
statsd-instrument-3.0.1 lib/statsd/instrument/log_sink.rb