Module: Meshchat::Debug

Defined in:
lib/meshchat/debug.rb

Overview

This file is stupid. But very helpful when debugging problems…

Class Method Summary collapse

Class Method Details

.connected_to_relayObject



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.message
  Display.error e.backtrace.join("\n").colorize(:red)
end

.disconnected_from_relayObject



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 message_being_dispatched(node, message)
  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: ' + message.type)
  Display.debug('DISPATCHING: ' + message.message.to_s)
end

.message_type_not_found(type) ⇒ Object



22
23
24
# File 'lib/meshchat/debug.rb', line 22

def message_type_not_found(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, message, e)
  Display.debug("#{message.class.name}: Issue connectiong to #{node.alias_name}@#{node.location}")
  Display.debug(e.message)
end

.received_message_from_relay(message, relay_url) ⇒ Object



42
43
44
45
46
# File 'lib/meshchat/debug.rb', line 42

def received_message_from_relay(message, relay_url)
  Display.debug('RECEIVING on RELAY: ' + relay_url)
  Display.debug('RECEIVING on RELAY: ')
  Display.debug(message)
end

.receiving_message(message) ⇒ Object



55
56
57
58
59
# File 'lib/meshchat/debug.rb', line 55

def receiving_message(message)
  Display.debug('RECEIVING: ' + message.type)
  Display.debug('RECEIVING: ' + message.sender.to_s)
  Display.debug('RECEIVING: ' + message.message.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 sending_message_over_relay(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_relayObject



30
31
32
# File 'lib/meshchat/debug.rb', line 30

def subscribed_to_relay
  Display.debug('Subscribed to relay...')
end