Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Alternate logger for Rails that emits syslog-style output. For use with pl_analyze gem.

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 README.rdoc
Octocat-spinner-32 Rakefile
Octocat-spinner-32 hodel_3000_compliant_logger.gemspec
README.rdoc

Hodel 3000 Compliant Logger

The Hodel 3000 Compliant Logger outputs like SyslogLogger (seattlerb.rubyforge.org/SyslogLogger/), except it doesn't need a syslog daemon running, such that your log come out exactly like syslog logs.

Mostly, this is intended to let you use tools that assume your log are in this syslog format, including:

See initial announcement here: nubyonrails.com/articles/a-hodel-3000-compliant-logger-for-the-rest-of-us

Installation and congiguration

gem install hodel_3000_compliant_logger

The main thing hodel_3000_complaint_logger provides is the Hodel3000ComplaintLogger class. It's a subclass of Logger (ruby-doc.org/core/classes/Logger.html), so you can use it as you would any Logger, really, except it outputs slightly different.

require 'hodel_3000_compliant_logger'
log = Hodel3000ComplaintLogger.new(STDOUT)
log.level = Logger::WARN

log.debug("Created logger")
log.info("Program started")
log.warn("Nothing to do!")

Most likely, you'll want to use it to replace the builtin Rails logger, by updating config/environment.rb:

Rails::Initializer.run do |config|

config.gem 'hodel_3000_compliant_logger'
begin
  require 'hodel_3000_compliant_logger'
  config.logger = Hodel3000CompliantLogger.new(config.log_path)
rescue
  $stderr.puts "Hodel3000CompliantLogger unavailable, oink will be disabled"
end

end

Note, the block inside Rails::Initializer runs before you environment is fully loaded, so you need this in a begin/rescue block so `rake gems:install` doesn't fall on its face.

NOTE

If you are using FastCGI, you may need to hard-code the hostname instead of using Socket.gethostname

Author

Geoffrey Grosenbach, with help from Eric Hodel

topfunky.com

Changes

  • Nov 29, 2007: Improvements and spec from Chris Bernard [logicleaf.com/]

Something went wrong with that request. Please try again.