Sha256: 1aeb9a212f736beacdd234d93cafbf94cde92178d798b037fa406837ac1cf650

Contents?: true

Size: 585 Bytes

Versions: 1

Compression:

Stored size: 585 Bytes

Contents

require 'file_safe_logger/version'
require 'logger'

class FileSafeLogger < Logger
  def initialize(logdev, shift_age = 0, shift_size = 1048576)
    super(nil, shift_age, shift_size)
    if logdev
      @logdev = FileSafeLogger::LogDevice.new(logdev, :shift_age => shift_age,
                                              :shift_size => shift_size)
    end
  end

  class LogDevice < Logger::LogDevice
    def write(message)
      unless FileTest.exist?(@filename)
        @dev.close rescue nil
        @dev = create_logfile(@filename)
      end
      super(message)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
file_safe_logger-0.1.0 lib/file_safe_logger.rb