Class: Log4r::FileOutputter
- Inherits:
-
Object
- Object
- Log4r::FileOutputter
- Defined in:
- lib/omf_base/log4r/file_outputter.rb
Overview
When daemonizing, the file handler gets closed and we fall over here. The following monkey patch retries once to open the file and write again
Instance Method Summary collapse
Instance Method Details
#write(data) ⇒ Object
end
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/omf_base/log4r/file_outputter.rb', line 19 def write(data) #puts ">>> #{data}" begin @out.print data @out.flush rescue IOError => ioe # recover from this instead of crash # retry once unless = true @out = File.new(@filename, (@trunc ? "w" : "a")) return write(data) end Logger.log_internal {"IOError in Outputter '#{@name}'!"} Logger.log_internal {ioe} close rescue NameError => ne Logger.log_internal {"Outputter '#{@name}' IO is #{@out.class}!"} Logger.log_internal {ne} close end = false end |