Sha256: 3757768da1667046685aefa7aa73496603ce98b3279e66bb60ee16ff9888039e

Contents?: true

Size: 698 Bytes

Versions: 2

Compression:

Stored size: 698 Bytes

Contents

module Toy
  module Logger
    extend ActiveSupport::Concern

    module ClassMethods
      OperationsToLogValueFor = [:get, :set, :del]

      def logger
        Toy.logger
      end

      def log_operation(operation, model, adapter, key, value=nil)
        if logger && logger.debug?
          logger.debug("TOYSTORE #{operation.to_s.upcase} #{model} :#{adapter.name} #{key.inspect}")
          logger.debug("  #{value.inspect}") if !value.nil? && OperationsToLogValueFor.include?(operation)
        end
      end
    end

    module InstanceMethods
      def logger
        Toy.logger
      end

      def log_operation(*args)
        self.class.log_operation(*args)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
toystore-0.8.3 lib/toy/logger.rb
toystore-0.8.2 lib/toy/logger.rb