Sha256: 95bba13537b3c604acab1625f2219678ada2211cfd90bbdc20cb998913316bd6

Contents?: true

Size: 769 Bytes

Versions: 6

Compression:

Stored size: 769 Bytes

Contents

module Alfa
  class QueryLogger
    @logs = []
    @num = 0
    class << self
      def log query, instance = nil, &block
        @num += 1
        if block_given?
          log = {:num => @num, :query => query, :instance => instance, :status => :started, :error => nil, :logger_hash => self.hash}
          @logs << log
          begin
            result = yield
          rescue StandardError => e
            log[:status] = :fail
            log[:error] = e.message
            raise e
          end
          log[:status] = :done
          return result
        else
          @logs << {:num => @num, :query => query, :instance => instance, :status => :flat, :logger_hash => self.hash}
        end
      end
      def logs
        @logs
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
alfa-0.0.8.pre lib/alfa/query_logger.rb
alfa-0.0.7.pre lib/alfa/query_logger.rb
alfa-0.0.6.pre lib/alfa/query_logger.rb
alfa-0.0.5.pre lib/alfa/query_logger.rb
alfa-0.0.4.pre lib/alfa/query_logger.rb
alfa-0.0.2.pre lib/alfa/query_logger.rb