class PerfectQueue::DaemonsLogger
Public Class Methods
new(dev, shift_age=0, shift_size=1048576)
click to toggle source
Calls superclass method
# File lib/perfectqueue/daemons_logger.rb, line 22 def initialize(dev, shift_age=0, shift_size=1048576) @stdout_hook = false @stderr_hook = false if dev.is_a?(String) @path = dev @io = File.open(@path, File::WRONLY|File::APPEND|File::CREAT) else @io = dev end super(@io, shift_size, shift_size) end
Public Instance Methods
close()
click to toggle source
# File lib/perfectqueue/daemons_logger.rb, line 70 def close if @path @io.close unless @io.closed? end nil end
hook_stderr!()
click to toggle source
# File lib/perfectqueue/daemons_logger.rb, line 41 def hook_stderr! STDERR.reopen(@io) @stderr_hook = true self end
hook_stdout!()
click to toggle source
# File lib/perfectqueue/daemons_logger.rb, line 34 def hook_stdout! return nil if @io == STDOUT STDOUT.reopen(@io) @stdout_hook = true self end
reopen()
click to toggle source
# File lib/perfectqueue/daemons_logger.rb, line 60 def reopen begin reopen! return true rescue # TODO log? return false end end
reopen!()
click to toggle source
# File lib/perfectqueue/daemons_logger.rb, line 47 def reopen! if @path @io.reopen(@path) if @stdout_hook STDOUT.reopen(@io) end if @stderr_hook STDERR.reopen(@io) end end nil end