core: use of the new core.log module:

/!\ this is a massive refactoring and was largely automated, it probably did bring some bugs /!\
This commit is contained in:
Goffi 2014-04-19 19:19:19 +02:00
commit 501bc92528

View file

@ -23,7 +23,8 @@ from sat.core.sat_main import MessageSentAndStored
from twisted.words.protocols.jabber import jid
from twisted.internet import defer
from twisted.python.failure import Failure
from logging import debug, info, warning, error
from sat.core.log import getLogger
log = getLogger(__name__)
PLUGIN_INFO = {
"name": "Text commands",
@ -43,7 +44,7 @@ class TextCommands(object):
# should be downloadable independently)
def __init__(self, host):
info(_("Text commands initialization"))
log.info(_("Text commands initialization"))
self.host = host
host.trigger.add("sendMessage", self.sendMessageTrigger)
self._commands = {}
@ -59,20 +60,20 @@ class TextCommands(object):
if attr.startswith('cmd_'):
cmd = getattr(instance, attr)
if not callable(cmd):
warning(_("Skipping not callable [%s] attribute") % attr)
log.warning(_("Skipping not callable [%s] attribute") % attr)
continue
cmd_name = attr[4:]
if not cmd_name:
warning(_("Skipping cmd_ method"))
log.warning(_("Skipping cmd_ method"))
if cmd_name in self._commands:
suff=2
while (cmd_name + str(suff)) in self._commands:
suff+=1
new_name = cmd_name + str(suff)
warning(_("Conflict for command [%(old_name)s], renaming it to [%(new_name)s]") % {'old_name': cmd_name, 'new_name': new_name})
log.warning(_("Conflict for command [%(old_name)s], renaming it to [%(new_name)s]") % {'old_name': cmd_name, 'new_name': new_name})
cmd_name = new_name
self._commands[cmd_name] = cmd
info(_("Registered text command [%s]") % cmd_name)
log.info(_("Registered text command [%s]") % cmd_name)
def addWhoIsCb(self, callback, priority=0):
"""Add a callback which give information to the /whois command
@ -160,7 +161,7 @@ class TextCommands(object):
def cmd_whois(self, mess_data, profile):
"""show informations on entity"""
debug("Catched whois command")
log.debug("Catched whois command")
entity = mess_data["unparsed"].strip()
@ -170,7 +171,7 @@ class TextCommands(object):
if self.host.plugins["XEP-0045"].isNickInRoom(room, entity, profile):
entity = u"%s/%s" % (room, entity)
except KeyError:
warning("plugin XEP-0045 is not present")
log.warning("plugin XEP-0045 is not present")
if not entity:
target_jid = mess_data["to"]