Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A ruby logger for logging via an AMQP exchange
Ruby
branch: metrics_agent

This branch is 18 commits ahead, 28 commits behind master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
test
.gitignore
Gemfile
LICENCES
Rakefile
Readme.rdoc
amqp_logging.gemspec

Readme.rdoc

AMQPLogging

A ruby logger class that logs to an AMQP exchange in addition to your default log device.

Basic Configuration

By default the logs are routed to the host, exchange and key specified in DEFAULT_OPTIONS. You can change the configuration when creating the logger object by specifying an argument hash:

require 'amqp_logging'

logging_config = { :routing_key => "applogging",
                   :host => AppConfig.amqp_logging.host,
                   :exchange => AppConfig.amqp_logging.exchange }

logger = AMQPLogging::Logger.new(config.log_path, logging_config)
config.logger = logger

With Rails 3 you will need to modify this a bit, as config.log_path no longer has the desired effect:

config.logger = AMQPLogging::Logger.new(config.paths.log.to_a.first, logging_config)

Routing Keys

You can set the routing key with a string or use a generator that respondes to call, receives the logline as the first argument and returns the routing key.

Example:

# You can use a lambda or whatever responds to #call as the routing key generator
AMQPRoutingKeyGenerator = lambda do |logline|
  if logline =~ /(?:engine\[([^\]]*)\])\: (Completed in|Processing|Session ID)?/
    key = "logs.app.#{$1}"
    key << ".statistics" unless $2.nil?
  else
    key = "logs.app.system"
  end
  key
end

AMQPLogging::Logger.new($stdout, :routing_key => AMQPRoutingKeyGenerator)

License

Copyright © 2010 Pascal Friederich Copyright © 2010 XING AG

See LICENSES for details.

Something went wrong with that request. Please try again.