Sha256: ccbfcfc86603227862dbf7367b61f274f769bdf044fb29b7706660a6f45d04a5

Contents?: true

Size: 845 Bytes

Versions: 1

Compression:

Stored size: 845 Bytes

Contents

module Redwood

class Logger
  @@instance = nil

  attr_reader :buf

  def initialize
    raise "only one Log can be defined" if @@instance
    @@instance = self
    @mode = LogMode.new
    @respawn = true
    @spawning = false # to prevent infinite loops!
  end

  ## must be called if you want to see anything!
  ## once called, will respawn if killed...
  def make_buf
    return if @mode.buffer || !BufferManager.instantiated? || !@respawn || @spawning
    @spawning = true
    @mode.buffer = BufferManager.instance.spawn "<log>", @mode, :hidden => true
    @spawning = false
  end

  def log s
#    $stderr.puts s
    @mode << "#{Time.now}: #{s.chomp}\n"
    make_buf
  end
  
  def self.method_missing m, *a
    @@instance = Logger.new unless @@instance
    @@instance.send m, *a
  end

  def self.buffer
    @@instance.buf
  end
end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sup-0.0.2 lib/sup/logger.rb