module Meshchat::Debug

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

Public Instance Methods

connected_to_relay() click to toggle source
# File lib/meshchat/debug.rb, line 34
def connected_to_relay
  Display.debug('Connected to relay...')
end
creating_input_failed(e) click to toggle source
# 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_relay() click to toggle source
# File lib/meshchat/debug.rb, line 38
def disconnected_from_relay
  Display.debug('Disconnected from relay...')
end
encryption_failed(node) click to toggle source
# 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) click to toggle source

TODO: extract this idea to a gem

- automatic logging of method calls
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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_relay() click to toggle source
# File lib/meshchat/debug.rb, line 30
def subscribed_to_relay
  Display.debug('Subscribed to relay...')
end