Skip to content

Instantly share code, notes, and snippets.

@unicornrainbow
Forked from rcrowley/unicorn.conf.rb
Created October 31, 2012 17:14
Show Gist options
  • Save unicornrainbow/3988400 to your computer and use it in GitHub Desktop.
Save unicornrainbow/3988400 to your computer and use it in GitHub Desktop.
Unicorn logging to syslog
class Syslogger
def initialize
read, @write = IO.pipe
fork do
@write.close
$stdin.reopen read
exec *%w(logger -trails)
end
read.close
@write.sync = true
end
def write(progname=nil, &block)
@write.puts "#{progname} #{block.call if block_given?}"
end
alias :debug :write
alias :info :write
alias :warn :write
alias :error :write
alias :fatal :write
end
logger Syslogger.new
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment