Module: Meshchat::Debug
- Defined in:
- lib/meshchat/debug.rb
Overview
This file is stupid. But very helpful when debugging problems…
Class Method Summary collapse
- .connected_to_relay ⇒ Object
- .creating_input_failed(e) ⇒ Object
- .disconnected_from_relay ⇒ Object
- .encryption_failed(node) ⇒ Object
-
.log(method_list) ⇒ Object
TODO: extract this idea to a gem - automatic logging of method calls.
- .message_being_dispatched(node, message) ⇒ Object
- .message_type_not_found(type) ⇒ Object
- .not_on_local_network(node) ⇒ Object
- .person_not_online(node, message, e) ⇒ Object
- .received_message_from_relay(message, relay_url) ⇒ Object
- .receiving_message(message) ⇒ Object
- .sending_message_over_relay(node, relay_pool) ⇒ Object
- .subscribed_to_relay ⇒ Object
Class Method Details
.connected_to_relay ⇒ Object
34 35 36 |
# File 'lib/meshchat/debug.rb', line 34 def connected_to_relay Display.debug('Connected to relay...') end |
.creating_input_failed(e) ⇒ Object
80 81 82 83 |
# File 'lib/meshchat/debug.rb', line 80 def creating_input_failed(e) Display.error e. Display.error e.backtrace.join("\n").colorize(:red) end |
.disconnected_from_relay ⇒ Object
38 39 40 |
# File 'lib/meshchat/debug.rb', line 38 def disconnected_from_relay Display.debug('Disconnected from relay...') end |
.encryption_failed(node) ⇒ Object
76 77 78 |
# File 'lib/meshchat/debug.rb', line 76 def encryption_failed(node) Display.info "Public key encryption for #{node.try(:alias_name) || 'unknown'} failed" end |
.log(method_list) ⇒ Object
TODO: extract this idea to a gem
- automatic logging of method calls
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/meshchat/debug.rb', line 10 def log(method_list) method_list = Array[method_list] method_list.each do |method| backup_name = "#{method}_bak".to_sym alias_method :backup_name, :method define_method(method) do |*args| Display.debug("##{method}: ") Display.debug(args.inspect) end end end |
.message_being_dispatched(node, message) ⇒ Object
61 62 63 64 65 66 67 68 69 |
# File 'lib/meshchat/debug.rb', line 61 def (node, ) Display.debug('DISPATCHING: ---------------------') Display.debug('DISPATCHING: u - ' + node.uid) Display.debug('DISPATCHING: a - ' + node.alias_name) Display.debug('DISPATCHING: r - ' + node.on_relay.to_s) Display.debug('DISPATCHING: l - ' + node.on_local_network.to_s) Display.debug('DISPATCHING: ' + .type) Display.debug('DISPATCHING: ' + ..to_s) end |
.message_type_not_found(type) ⇒ Object
22 23 24 |
# File 'lib/meshchat/debug.rb', line 22 def (type) Display.debug('Type not found: ' + type.to_s) end |
.not_on_local_network(node) ⇒ Object
26 27 28 |
# File 'lib/meshchat/debug.rb', line 26 def not_on_local_network(node) Display.debug('SENDING: ' + node.alias_name + ' is not on the local network') end |
.person_not_online(node, message, e) ⇒ Object
71 72 73 74 |
# File 'lib/meshchat/debug.rb', line 71 def person_not_online(node, , e) Display.debug("#{.class.name}: Issue connectiong to #{node.alias_name}@#{node.location}") Display.debug(e.) end |
.received_message_from_relay(message, relay_url) ⇒ Object
42 43 44 45 46 |
# File 'lib/meshchat/debug.rb', line 42 def (, relay_url) Display.debug('RECEIVING on RELAY: ' + relay_url) Display.debug('RECEIVING on RELAY: ') Display.debug() end |
.receiving_message(message) ⇒ Object
55 56 57 58 59 |
# File 'lib/meshchat/debug.rb', line 55 def () Display.debug('RECEIVING: ' + .type) Display.debug('RECEIVING: ' + .sender.to_s) Display.debug('RECEIVING: ' + ..to_s) end |
.sending_message_over_relay(node, relay_pool) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/meshchat/debug.rb', line 48 def (node, relay_pool) Display.debug('SENDING on RELAY ---------------------- ') Display.debug('SENDING on RELAY: ' + node.alias_name) Display.debug('SENDING on RELAY: ' + node.uid) Display.debug('SENDING on RELAY: ' + relay_pool._active_relay._url) end |
.subscribed_to_relay ⇒ Object
30 31 32 |
# File 'lib/meshchat/debug.rb', line 30 def subscribed_to_relay Display.debug('Subscribed to relay...') end |