Skip to content
This repository has been archived by the owner on Feb 11, 2019. It is now read-only.

Commit

Permalink
implemented log.debug/log.info changes suggested by hodgestar, rename…
Browse files Browse the repository at this point in the history
…d print_error to log_error
  • Loading branch information
annasborysova committed Jul 7, 2015
1 parent 680c35c commit 4ab0078
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions vxyowsup/whatsapp.py
Expand Up @@ -56,19 +56,19 @@ def setup_transport(self):
stack_client = self.stack_client = StackClient(CREDENTIALS, self)
self.client_d = deferToThread(stack_client.client_start)
self.client_d.addErrback(self.catch_exit)
self.client_d.addErrback(self.print_error)
self.client_d.addErrback(self.log_error)

@defer.inlineCallbacks
def teardown_transport(self):
log.debug("Stopping client ...")
log.info("Stopping client ...")
self.stack_client.client_stop()
yield self.client_d
yield self.redis._close()
log.debug("Loop done.")
log.info("Loop done.")

def handle_outbound_message(self, message):
# message is a vumi.message.TransportUserMessage
log.info('Sending %r' % (message.to_json(),))
log.debug('Sending %r' % (message.to_json(),))
msg = TextMessageProtocolEntity(message['content'], to=message['to_addr'] + '@s.whatsapp.net')
self.redis.setex(msg.getId(), self.config.ack_timeout, message['message_id'])
self.stack_client.send_to_stack(msg)
Expand All @@ -87,9 +87,9 @@ def _send_delivery_report(self, whatsapp_id):

def catch_exit(self, f):
f.trap(WhatsAppClientDone)
log.debug("Yowsup client killed.")
log.info("Yowsup client killed.")

def print_error(self, f):
def log_error(self, f):
log.debug(f)

This comment has been minimized.

Copy link
@hodgestar

hodgestar Jul 7, 2015

Contributor

I guess we should use log.error here since that handles Twisted failure objects nicely?

return f

Expand All @@ -116,10 +116,10 @@ def client_start(self):
self.stack.loop(discrete=0, count=1, timeout=1)

def client_stop(self):
log.debug("Stopping client ...")
log.info("Stopping client ...")

def _stop():
log.debug("Sending disconnect ...")
log.info("Sending disconnect ...")
self.whatsapp_interface.disconnect()

def _kill():
Expand Down

0 comments on commit 4ab0078

Please sign in to comment.