Sha256: 14d03112fab812e0a763bbed9f718dcba9161d5e5cc866032ed4ab33e2c56f69

Contents?: true

Size: 676 Bytes

Versions: 2

Compression:

Stored size: 676 Bytes

Contents

module Pundit
  module Logger
    module Logging
      # Logs a message to the logger configured in
      # Pundit::Logger.logger.
      #
      # Uses tagged logging, if configured using
      # Pundit::Logger.logger_tag
      #
      # @param [String] Message to write to the logger
      def log(message)
        if logger.respond_to?(:tagged) && logger_tag
          logger.tagged(logger_tag) do
            write_message message
          end
        else
          write_message message
        end
      end

      private

      def write_message(message)
        logger.public_send(
          log_level.to_sym,
          message
        )
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pundit_logger-0.1.1 lib/pundit_logger/logging.rb
pundit_logger-0.1.0 lib/pundit_logger/logging.rb