class NchanTools::Subscriber::Logger

Public Class Methods

new() click to toggle source
# File lib/nchan_tools/pubsub.rb, line 221
def initialize
  @log = []
end

Public Instance Methods

filter(opt) click to toggle source
# File lib/nchan_tools/pubsub.rb, line 229
def filter(opt)
  opt[:id] = opt[:id].to_sym if opt[:id]
  opt[:type] = opt[:type].to_sym if opt[:type]
  @log.select do |l|
    true unless ((opt[:id] && opt[:id] != l[:id]) ||
                 (opt[:type] && opt[:type] != l[:type]) ||
                 (opt[:data] && !l.match(opt[:data])))
  end
end
log(id, type, msg=nil) click to toggle source
# File lib/nchan_tools/pubsub.rb, line 225
def log(id, type, msg=nil)
  @log << {time: Time.now.to_f.round(4), id: id.to_sym, type: type, data: msg}
end
show() click to toggle source
# File lib/nchan_tools/pubsub.rb, line 239
def show
  @log
end
to_s() click to toggle source
# File lib/nchan_tools/pubsub.rb, line 243
def to_s
  @log.map {|l| "#{l.id} (#{l.type}) #{msg.to_s}"}.join "\n"
end