### Home Classes Methods

### In Files

- lib/amqp/deprecated/logger.rb

### Parent

Object

### Methods

- ::disable
- ::disabled?
- ::enable
- ::new
- ::printer
- #log
- #method_missing
- #print
- #printer

### Class/Module Index

Quicksearch

- AMQP
- AMQP::BitSet
- AMQP::BlankSlate
- AMQP::Broker
- AMQP::Channel
- AMQP::ChannelClosedError
- AMQP::Client
- AMQP::Consumer
- AMQP::Error
- AMQP::Exchange
- AMQP::Header
- AMQP::IncompatibleOptionsError
- AMQP::IntAllocator
- AMQP::Integration
- AMQP::Integration::Rails
- AMQP::Logger
- AMQP::PossibleAuthenticationFailureError
- AMQP::Queue
- AMQP::RPC
- AMQP::RPC::Client
- AMQP::RPC::Server
- AMQP::Session
- AMQP::TCPConnectionFailed
- AMQP::Utilities
- AMQP::Utilities::EventLoopHelper
- AMQP::Utilities::ServerType
- MQ
- MQ::Exchange
- MQ::Logger
- MQ::Queue
- EM
- Object

No matching classes.

# AMQP::Logger

@private

### Attributes

base[R]
prop[R]

### Public Class Methods

disable() click to toggle source

    # File lib/amqp/deprecated/logger.rb, line 87
    def self.disable
      @disabled = true
    end

disabled?() click to toggle source

    # File lib/amqp/deprecated/logger.rb, line 79
    def self.disabled?
      !!@disabled
    end

enable() click to toggle source

    # File lib/amqp/deprecated/logger.rb, line 83
    def self.enable
      @disabled = false
    end

new(*args, &block) click to toggle source

    # File lib/amqp/deprecated/logger.rb, line 5
    def initialize(*args, &block)
      opts = args.pop if args.last.is_a? Hash
      opts ||= {}

      printer(block) if block

      @prop = opts
      @tags = ([:timestamp] + args).uniq
    end

printer(&block) click to toggle source

    # File lib/amqp/deprecated/logger.rb, line 74
    def self.printer &block
      @printer = block if block
      @printer
    end

### Public Instance Methods

log(severity, *args) click to toggle source

    # File lib/amqp/deprecated/logger.rb, line 18
    def log(severity, *args)
      opts = args.pop if args.last.is_a? Hash and args.size != 1
      opts ||= {}
      opts = @prop.clone.update(opts)

      data = args.shift

      data = {:type => :exception,
              :name => data.class.to_s.intern,
              :backtrace => data.backtrace,
              :message => data.message} if data.is_a? Exception

      (@tags + args).each do |tag|
        tag = tag.to_sym
        case tag
        when :timestamp
          opts.update :timestamp => Time.now
        when :hostname
          @hostname ||= { :hostname => `hostname`.strip }
          opts.update @hostname
        when :process
          @process_id ||= { :process_id => Process.pid,
                            :process_name => $0,
                            :process_parent_id => Process.ppid,
                            :thread_id => Thread.current.object_id }
          opts.update :process => @process_id
        else
          (opts[:tags] ||= []) << tag
        end
      end

      opts.update(:severity => severity,
                  :msg => data)

      print(opts)
      unless Logger.disabled?
        AMQP::Channel.new.fanout('logging', :durable => true).publish Marshal.dump(opts)
      end

      opts
    end

Also aliased as: method_missing
method_missing(severity, *args) click to toggle source
Alias for: log
print(data = nil, &block) click to toggle source

    # File lib/amqp/deprecated/logger.rb, line 61
    def print(data = nil, &block)
      if block
        @printer = block
      elsif data.is_a? Proc
        @printer = data
      elsif data
        (pr = @printer || self.class.printer) and pr.call(data)
      else
        @printer
      end
    end

Also aliased as: printer
printer(data = nil, &block) click to toggle source
Alias for: print

[Validate]

Generated with the Darkfish Rdoc Generator 2.