Sha256: cce4a18a456ebe31592f668bae16e61f7c0c843e438bb9593af1e10f9444374b
Contents?: true
Size: 1.16 KB
Versions: 2
Compression:
Stored size: 1.16 KB
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, :system => true @spawning = false end def log s # $stderr.puts s make_buf prefix = "#{Time.now}: " padding = " " * prefix.length first = true s.split(/[\r\n]/).each do |l| l = l.chomp if first first = false @mode << "#{prefix}#{l}\n" else @mode << "#{padding}#{l}\n" end end $stderr.puts "[#{Time.now}] #{s.chomp}" unless BufferManager.instantiated? && @mode.buffer 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sup-0.8.1 | lib/sup/logger.rb |
sup-0.8 | lib/sup/logger.rb |