Sha256: 1cca047fc3a0ea38f99d06ad56ba1334639ae595379a1a2e802eafaae92c2025

Contents?: true

Size: 774 Bytes

Versions: 3

Compression:

Stored size: 774 Bytes

Contents

module Pwwka
  module Logging

    delegate :fatal, :error, :warn, :info, :debug, to: :logger

    def logger
      Pwwka.configuration.logger
    end

    LEVELS = {
      fatal: 5,
      error: 4,
      warn: 3,
      info: 2,
      debug: 1,
    }

    def logf(format,params)
      level = params.delete(:at) || Pwwka.configuration.log_level
      params[:payload] = params["payload"] if params["payload"]
      if Pwwka.configuration.omit_payload_from_log?(level)
        params[:payload] = "[omitted]" if params[:payload]
      end
      message = format % params

      if Pwwka.configuration.log_hooks.select { |key, _value| message.match key }.each { |_key, value| value.call(message, params) }.empty?
        logger.send(level,message)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pwwka-1.0.0 lib/pwwka/logging.rb
pwwka-1.0.0.RC1 lib/pwwka/logging.rb
pwwka-0.24.0 lib/pwwka/logging.rb