Class: Bidi2pdf::Notifications::LoggingSubscriber

Inherits:
Object
  • Object
show all
Includes:
LoggingSubscriberActions
Defined in:
lib/bidi2pdf/notifications/logging_subscriber.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from LoggingSubscriberActions

#handle_response, #network_event_received, #network_idle, #page_loaded, #print, #send_cmd, #send_cmd_and_wait, #session_close

Constructor Details

#initialize(logger: Logger.new($stdout)) ⇒ LoggingSubscriber

rubocop: disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity



110
111
112
113
114
115
116
117
118
119
120
# File 'lib/bidi2pdf/notifications/logging_subscriber.rb', line 110

def initialize(logger: Logger.new($stdout))
  @logger = logger
  Bidi2pdf.notification_service&.subscribe("handle_response.bidi2pdf", &method(:handle_response))
  Bidi2pdf.notification_service&.subscribe("send_cmd.bidi2pdf", &method(:send_cmd))
  Bidi2pdf.notification_service&.subscribe("send_cmd_and_wait.bidi2pdf", &method(:send_cmd_and_wait))
  Bidi2pdf.notification_service&.subscribe("session_close.bidi2pdf", &method(:session_close))
  Bidi2pdf.notification_service&.subscribe("network_idle.bidi2pdf", &method(:network_idle))
  Bidi2pdf.notification_service&.subscribe("page_loaded.bidi2pdf", &method(:page_loaded))
  Bidi2pdf.notification_service&.subscribe("network_event_received.bidi2pdf", &method(:network_event_received))
  Bidi2pdf.notification_service&.subscribe("print.bidi2pdf", &method(:network_event_received))
end

Instance Attribute Details

#loggerObject

Returns the value of attribute logger.



107
108
109
# File 'lib/bidi2pdf/notifications/logging_subscriber.rb', line 107

def logger
  @logger
end

Instance Method Details

#unsubscribeObject



122
123
124
125
126
127
128
129
130
131
# File 'lib/bidi2pdf/notifications/logging_subscriber.rb', line 122

def unsubscribe
  Bidi2pdf.notification_service&.unsubscribe("handle_response.bidi2pdf", &method(:handle_response))
  Bidi2pdf.notification_service&.unsubscribe("send_cmd.bidi2pdf", &method(:send_cmd))
  Bidi2pdf.notification_service&.unsubscribe("send_cmd_and_wait.bidi2pdf", &method(:send_cmd_and_wait))
  Bidi2pdf.notification_service&.unsubscribe("session_close.bidi2pdf", &method(:session_close))
  Bidi2pdf.notification_service&.unsubscribe("network_idle.bidi2pdf", &method(:network_idle))
  Bidi2pdf.notification_service&.unsubscribe("page_loaded.bidi2pdf", &method(:page_loaded))
  Bidi2pdf.notification_service&.unsubscribe("network_event_received.bidi2pdf", &method(:network_event_received))
  Bidi2pdf.notification_service&.unsubscribe("print.bidi2pdf", &method(:network_event_received))
end