Mercurial > libervia-backend
diff src/plugins/plugin_xep_0095.py @ 993:301b342c697a
core: use of the new core.log module:
/!\ this is a massive refactoring and was largely automated, it probably did bring some bugs /!\
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 19 Apr 2014 19:19:19 +0200 |
parents | c6d8fc63b1db |
children | 069ad98b360d |
line wrap: on
line diff
--- a/src/plugins/plugin_xep_0095.py Sat Apr 19 16:48:26 2014 +0200 +++ b/src/plugins/plugin_xep_0095.py Sat Apr 19 19:19:19 2014 +0200 @@ -19,7 +19,8 @@ from sat.core.i18n import _ from sat.core.constants import Const as C -from logging import debug, info, error +from sat.core.log import getLogger +log = getLogger(__name__) from twisted.words.xish import domish from twisted.words.protocols.jabber import client import uuid @@ -52,7 +53,7 @@ class XEP_0095(object): def __init__(self, host): - info(_("Plugin XEP_0095 initialization")) + log.info(_("Plugin XEP_0095 initialization")) self.host = host self.si_profiles = {} # key: SI profile, value: callback @@ -69,7 +70,7 @@ """This method is called on stream initiation (XEP-0095 #3.2) @param iq_el: IQ element @param profile: %(doc_profile)s""" - info(_("XEP-0095 Stream initiation")) + log.info(_("XEP-0095 Stream initiation")) iq_el.handled = True si_el = iq_el.firstChildElement() si_id = si_el.getAttribute('id') @@ -110,7 +111,7 @@ @param iq_id: IQ id @param to_jid: recipient @param profile: %(doc_profile)s""" - self.sendError(iq_id, to_jid, 500, 'cancel', {'custom': 'failed'}, profile=profile) # as there is no error code for failed transfer, we use 500 (undefined-condition) + self.sendError(iq_id, to_jid, 500, 'cancel', {'custom': 'failed'}, profile=profile) # as there is no lerror code for failed transfer, we use 500 (undefined-condition) def sendError(self, iq_id, to_jid, err_code, err_type='cancel', data={}, profile=C.PROF_KEY_NONE): """Send IQ error as a result @@ -154,7 +155,7 @@ @param profile: %(doc_profile)s""" _client = self.host.getClient(profile) assert(_client) - info(_("sending stream initiation accept answer")) + log.info(_("sending stream initiation accept answer")) result = domish.Element((None, 'iq')) result['type'] = 'result' result['id'] = iq_id @@ -176,12 +177,12 @@ @return: session id, offer""" current_jid, xmlstream = self.host.getJidNStream(profile_key) if not xmlstream: - error(_('Asking for an non-existant or not connected profile')) + log.error(_('Asking for an non-existant or not connected profile')) return "" offer = client.IQ(xmlstream, 'set') sid = str(uuid.uuid4()) - debug(_("Stream Session ID: %s") % offer["id"]) + log.debug(_("Stream Session ID: %s") % offer["id"]) offer["from"] = current_jid.full() offer["to"] = to_jid.full()