Class: ParallelCucumber::CustomLogger
- Inherits:
-
Logger
- Object
- Logger
- ParallelCucumber::CustomLogger
- Defined in:
- lib/parallel_cucumber/logger.rb
Instance Method Summary collapse
-
#initialize ⇒ CustomLogger
constructor
A new instance of CustomLogger.
- #synch ⇒ Object
- #update_into(other_logger) ⇒ Object
Constructor Details
#initialize ⇒ CustomLogger
Returns a new instance of CustomLogger.
5 6 7 8 9 10 |
# File 'lib/parallel_cucumber/logger.rb', line 5 def initialize(*) super @mark = 0 # Don't want to log half-lines. @incomplete_line = nil end |
Instance Method Details
#synch ⇒ Object
12 13 14 |
# File 'lib/parallel_cucumber/logger.rb', line 12 def synch mutex.synchronize { yield self } end |
#update_into(other_logger) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/parallel_cucumber/logger.rb', line 16 def update_into(other_logger) # TODO: This should write the #teamcity block wrapper: update(other_logger, 'qa-w12> precheck') etc. @logdev.dev.fsync # Helpful, but inadequate: a child process might still have buffered stuff. other_logger.synch do |l| l << File.open(@logdev.filename || @logdev.dev.path) do |f| begin f.seek(@mark) lines = f.readlines if @incomplete_line && lines.count > 0 lines[0] = @incomplete_line + lines[0] @incomplete_line = nil end unless lines.last && lines.last.end_with?("\n", "\r") @incomplete_line = lines.pop end lines.join ensure @mark = f.tell end end end end |