Skip to content

Instantly share code, notes, and snippets.

@nofxx
Created February 9, 2012 10:25
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save nofxx/1779106 to your computer and use it in GitHub Desktop.
Resque syslog (via log4r)
require 'log4r'
require 'log4r/outputter/syslogoutputter'
require 'resque/failure/multiple'
require 'resque/failure/redis'
module Resque
module Failure
class Syslog < Base
# Define your logger, change as needed.
def logger
unless @logger
@logger = Log4r::Logger.new 'resque'
@logger.outputters = Log4r::SyslogOutputter.new 'resque',
:ident => 'resque', :logopt => 'foo', :facility => 'local'
end
@logger
end
# We are using a two line log here: Resume and backtrace follow.
def save
logger.error "#{worker} #{queue} #{payload} #{exception.class}"
logger.error "#{exception} -- #{exception.backtrace.join('\n')}"
end
end
end
end
# Use multiple failure backends (Redis and Syslog)
Resque::Failure::Multiple.classes = [Resque::Failure::Redis, Resque::Failure::Syslog]
Resque::Failure.backend = Resque::Failure::Multiple
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment