Sha256: 497c76f43f9a525f59260be1ae59ce0293f4d7bb5acff30aa885d4b1181d08ac

Contents?: true

Size: 441 Bytes

Versions: 140

Compression:

Stored size: 441 Bytes

Contents

# frozen_string_literal: true

require "logger"
require "set"

# Subclass of logger with method to only log a warning once
# prevents the log from filling up with repeated messages.
module Appsignal
  class Logger < ::Logger
    def seen_keys
      @seen_keys ||= Set.new
    end

    def warn_once_then_debug(key, message)
      if !seen_keys.add?(key).nil?
        warn message
      else
        debug message
      end
    end
  end
end

Version data entries

140 entries across 140 versions & 1 rubygems

Version Path
appsignal-3.0.15-java lib/appsignal/logger.rb
appsignal-3.0.15 lib/appsignal/logger.rb
appsignal-3.0.14-java lib/appsignal/logger.rb
appsignal-3.0.14 lib/appsignal/logger.rb
appsignal-3.0.13-java lib/appsignal/logger.rb
appsignal-3.0.13 lib/appsignal/logger.rb
appsignal-3.0.12-java lib/appsignal/logger.rb
appsignal-3.0.12 lib/appsignal/logger.rb
appsignal-3.0.11-java lib/appsignal/logger.rb
appsignal-3.0.11 lib/appsignal/logger.rb
appsignal-3.0.10-java lib/appsignal/logger.rb
appsignal-3.0.10 lib/appsignal/logger.rb
appsignal-2.11.10-java lib/appsignal/logger.rb
appsignal-2.11.10 lib/appsignal/logger.rb
appsignal-3.0.9-java lib/appsignal/logger.rb
appsignal-3.0.9 lib/appsignal/logger.rb
appsignal-3.0.8-java lib/appsignal/logger.rb
appsignal-3.0.8 lib/appsignal/logger.rb
appsignal-3.0.7-java lib/appsignal/logger.rb
appsignal-3.0.7 lib/appsignal/logger.rb