module TeeLogger::LoggerExtensions

Extensions for the ruby logger

Attributes

flush_interval[RW]
teelogger_io[RW]

Public Instance Methods

auto_flush() click to toggle source

This function invokes flush if it's been invoked more often than flush_interval.

# File lib/teelogger/extensions.rb, line 34
def auto_flush
  if @written.nil?
    @written = 0
  end

  @written += 1

  if @written >= self.flush_interval
    self.flush
    @written = 0
  end
end
flush() click to toggle source

Flush ruby and OS buffers for this logger

# File lib/teelogger/extensions.rb, line 17
def flush
  if @teelogger_io.nil?
    raise "TeeLogger logger without IO object, can't do anything"
  end

  @teelogger_io.flush
  begin
    @teelogger_io.fsync
  rescue NotImplementedError, Errno::EINVAL
    # pass
  end
end