# class ActiveLdap::LogSubscriber

### Public Class Methods

new() click to toggle source
Calls superclass method

    # File lib/active_ldap/log_subscriber.rb, line 16
    def initialize
      super
      @odd = false
    end

reset_runtime() click to toggle source

    # File lib/active_ldap/log_subscriber.rb, line 11
    def self.reset_runtime
      rt, self.runtime = runtime, 0
      rt
    end

runtime() click to toggle source

    # File lib/active_ldap/log_subscriber.rb, line 7
    def self.runtime
      Thread.current["active_ldap_runtime"] ||= 0
    end

runtime=(value) click to toggle source

    # File lib/active_ldap/log_subscriber.rb, line 3
    def self.runtime=(value)
      Thread.current["active_ldap_runtime"] = value
    end

### Public Instance Methods

log_info(event) click to toggle source

    # File lib/active_ldap/log_subscriber.rb, line 21
    def log_info(event)
      self.class.runtime += event.duration
      return unless logger.debug?

      payload = event.payload
      label = payload[:name]
      label += ": FAILED" if payload[:info][:exception]
      name = 'LDAP: %s (%.1fms)' % [label, event.duration]
      info = payload[:info].inspect

      if odd?
        name = color(name, CYAN, true)
        info = color(info, nil, true)
      else
        name = color(name, MAGENTA, true)
      end

      debug "  #{name} #{info}"
    end

logger() click to toggle source

    # File lib/active_ldap/log_subscriber.rb, line 45
    def logger
      ActiveLdap::Base.logger
    end

odd?() click to toggle source

    # File lib/active_ldap/log_subscriber.rb, line 41
    def odd?
      @odd = !@odd
    end