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.24-java lib/appsignal/logger.rb
appsignal-3.0.24 lib/appsignal/logger.rb
appsignal-3.0.23-java lib/appsignal/logger.rb
appsignal-3.0.23 lib/appsignal/logger.rb
appsignal-3.0.22-java lib/appsignal/logger.rb
appsignal-3.0.22 lib/appsignal/logger.rb
appsignal-3.0.21-java lib/appsignal/logger.rb
appsignal-3.0.21 lib/appsignal/logger.rb
appsignal-3.0.21.alpha.1-java lib/appsignal/logger.rb
appsignal-3.0.21.alpha.1 lib/appsignal/logger.rb
appsignal-3.0.20-java lib/appsignal/logger.rb
appsignal-3.0.20 lib/appsignal/logger.rb
appsignal-3.0.19-java lib/appsignal/logger.rb
appsignal-3.0.19 lib/appsignal/logger.rb
appsignal-3.0.18-java lib/appsignal/logger.rb
appsignal-3.0.18 lib/appsignal/logger.rb
appsignal-3.0.17-java lib/appsignal/logger.rb
appsignal-3.0.17 lib/appsignal/logger.rb
appsignal-3.0.16-java lib/appsignal/logger.rb
appsignal-3.0.16 lib/appsignal/logger.rb