Created
August 17, 2010 20:03
-
-
Save rcrowley/531749 to your computer and use it in GitHub Desktop.
Unicorn logging to syslog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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