Sha256: 153d5b28a9eb4fd555133c943ca8dc2792b0d49b9532b2836609cde4aa011512

Contents?: true

Size: 910 Bytes

Versions: 33

Compression:

Stored size: 910 Bytes

Contents

module Zookeeper
  module Logger
    def self.wrapped_logger
      if defined?(@@wrapped_logger)
        @@wrapped_logger 
      else
        @@wrapped_logger = ::Logger.new(STDERR).tap { |l| l.level = ::Logger::FATAL }
      end
    end

    def self.wrapped_logger=(log)
      @@wrapped_logger = log
    end

    # @private
    module ClassMethods
      def logger
        ::Zookeeper.logger || ForwardingLogger.for(::Zookeeper::Logger.wrapped_logger, _zk_logger_name)
      end
    end

    def self.included(base)
      # return false if base < self    # avoid infinite recursion
      base.extend(ClassMethods)
    end

    private
      def log_realtime(what)
        logger.debug do
          t = Benchmark.realtime { yield }
          "#{what} took #{t} sec"
        end
      end

      def logger
        @logger ||= (::Zookeeper.logger || self.class.logger)
      end
  end # Logger
end # Zookeeper

Version data entries

33 entries across 33 versions & 2 rubygems

Version Path
zookeeper-1.5.5 lib/zookeeper/logger.rb
zookeeper-1.5.5-java lib/zookeeper/logger.rb
zookeeper-1.5.4 lib/zookeeper/logger.rb
zookeeper-1.5.4-java lib/zookeeper/logger.rb
zookeeper-1.5.3 lib/zookeeper/logger.rb
zookeeper-1.5.3-java lib/zookeeper/logger.rb
zookeeper-ng-1.5.2.1 lib/zookeeper/logger.rb
zookeeper-ng-1.5.2.1-java lib/zookeeper/logger.rb
zookeeper-1.5.1-java lib/zookeeper/logger.rb
zookeeper-1.5.1 lib/zookeeper/logger.rb
zookeeper-1.5.0-java lib/zookeeper/logger.rb
zookeeper-1.5.0 lib/zookeeper/logger.rb
zookeeper-ng-1.5 lib/zookeeper/logger.rb
zookeeper-1.4.11 lib/zookeeper/logger.rb
zookeeper-1.4.11-java lib/zookeeper/logger.rb
zookeeper-1.4.10 lib/zookeeper/logger.rb
zookeeper-1.4.10-java lib/zookeeper/logger.rb
zookeeper-1.4.9 lib/zookeeper/logger.rb
zookeeper-1.4.9-java lib/zookeeper/logger.rb
zookeeper-1.4.8 lib/zookeeper/logger.rb