In Files

  • logger.rb

Parent

Methods

Logger::LogDevice

Constants

SiD

Attributes

dev[R]
filename[R]

Public Class Methods

new(log = nil, opt = {}) click to toggle source
 
               # File logger.rb, line 480
def initialize(log = nil, opt = {})
  @dev = @filename = @shift_age = @shift_size = nil
  @mutex = LogDeviceMutex.new
  if log.respond_to?(:write) and log.respond_to?(:close)
    @dev = log
  else
    @dev = open_logfile(log)
    @dev.sync = true
    @filename = log
    @shift_age = opt[:shift_age] || 7
    @shift_size = opt[:shift_size] || 1048576
  end
end
            

Public Instance Methods

close() click to toggle source
 
               # File logger.rb, line 507
def close
  @mutex.synchronize do
    @dev.close
  end
end
            
write(message) click to toggle source
 
               # File logger.rb, line 494
def write(message)
  @mutex.synchronize do
    if @shift_age and @dev.respond_to?(:stat)
      begin
        check_shift_log
      rescue
        raise Logger::ShiftingError.new("Shifting failed. #{$!}")
      end
    end
    @dev.write(message)
  end
end