Skip to content

Instantly share code, notes, and snippets.

@rcrowley
Created August 17, 2010 20:03
Show Gist options
  • Save rcrowley/531749 to your computer and use it in GitHub Desktop.
Save rcrowley/531749 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