activitypub-academy/app/lib/activity_logger.rb
2023-01-14 17:12:20 +01:00

26 lines
417 B
Ruby

# frozen_string_literal: true
class ActivityLogger
@@loggers = Hash.new { |hash, key| hash[key] = [] }
def self.register(id, sse)
@@loggers[id] << sse
end
def self.unregister(id, sse)
@@loggers[id].delete(sse)
end
def self.log(id, event)
@@loggers[id].each do |logger|
logger.write event
rescue
puts 'rescued'
end
end
def self.reset
@@loggers.clear
end
end