class DbSucker::Application::SklavenTreiber::LogSpool
Attributes
original[R]
spool[R]
Public Class Methods
new(original)
click to toggle source
# File lib/db_sucker/application/sklaven_treiber/log_spool.rb, line 7 def initialize original @original = original @enabled = true @spool = [] @monitor = Monitor.new end
Public Instance Methods
clear()
click to toggle source
# File lib/db_sucker/application/sklaven_treiber/log_spool.rb, line 24 def clear sync { @spool.clear } end
disable(void_spool = false, &block)
click to toggle source
# File lib/db_sucker/application/sklaven_treiber/log_spool.rb, line 28 def disable void_spool = false, &block sync do @enabled = false (void_spool && clear) || (block && spooldown(&block)) end end
enable()
click to toggle source
# File lib/db_sucker/application/sklaven_treiber/log_spool.rb, line 18 def enable sync do @enabled = true end end
print(*args)
click to toggle source
# File lib/db_sucker/application/sklaven_treiber/log_spool.rb, line 47 def print *args sync { @enabled ? (@spool << [:print, args, Time.current]) : @original.send(:print, *args) } end
puts(*args)
click to toggle source
# File lib/db_sucker/application/sklaven_treiber/log_spool.rb, line 43 def puts *args sync { @enabled ? (@spool << [:puts, args, Time.current]) : @original.send(:puts, *args) } end
spooldown() { |e| ... }
click to toggle source
# File lib/db_sucker/application/sklaven_treiber/log_spool.rb, line 35 def spooldown sync do while e = @spool.shift yield(e + [original]) end end end
sync() { || ... }
click to toggle source
# File lib/db_sucker/application/sklaven_treiber/log_spool.rb, line 14 def sync @monitor.synchronize { yield } end
warn(*args)
click to toggle source
# File lib/db_sucker/application/sklaven_treiber/log_spool.rb, line 51 def warn *args sync { @enabled ? (@spool << [:warn, args, Time.current]) : @original.send(:warn, *args) } end