diff src/plugins/plugin_exp_command_export.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 1fe00f0c9a91
children 0befb14ecf62
line wrap: on
line diff
--- a/src/plugins/plugin_exp_command_export.py	Sat Apr 19 16:48:26 2014 +0200
+++ b/src/plugins/plugin_exp_command_export.py	Sat Apr 19 19:19:19 2014 +0200
@@ -18,7 +18,8 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 from sat.core.i18n import _
-from logging import debug, info, warning, error
+from sat.core.log import getLogger
+log = getLogger(__name__)
 from twisted.words.protocols.jabber import jid
 from twisted.internet import reactor, protocol
 
@@ -47,13 +48,13 @@
 
     def _clean(self, data):
         if not data:
-            error ("data should not be empty !")
+            log.error ("data should not be empty !")
             return u""
         decoded = data.decode('utf-8', 'ignore')[:-1 if data[-1] == '\n' else None]
         return clean_ustr(decoded)
 
     def connectionMade(self):
-        info("connectionMade :)")
+        log.info("connectionMade :)")
 
     def outReceived(self, data):
         self.parent.host.sendMessage(self.target, self._clean(data), no_trigger=True, profile_key=self.profile) 
@@ -62,7 +63,7 @@
         self.parent.host.sendMessage(self.target, self._clean(data), no_trigger=True, profile_key=self.profile) 
 
     def processEnded(self, reason):
-        info (u"process finished: %d" % (reason.value.exitCode,))
+        log.info (u"process finished: %d" % (reason.value.exitCode,))
         self.parent.removeProcess(self.target, self)
 
     def write(self, message):
@@ -83,7 +84,7 @@
     #     this is specially true if we have other triggers.
 
     def __init__(self, host):
-        info(_("Plugin command export initialization"))
+        log.info(_("Plugin command export initialization"))
         self.host = host
         self.spawned = {} # key = entity
         host.trigger.add("MessageReceived", self.MessageReceivedTrigger, priority=10000)
@@ -109,7 +110,7 @@
             body = [e for e in message.elements() if e.name == 'body'][0]
         except IndexError:
             # do not block message without body (chat state notification...)
-            warning("No body element found in message, following normal behaviour")
+            log.warning("No body element found in message, following normal behaviour")
             return True
 
         mess_data = unicode(body) + '\n'
@@ -141,7 +142,7 @@
         """
         profile = self.host.memory.getProfileName(profile_key)
         if not profile:
-            warning("Unknown profile [%s]" % (profile,))
+            log.warning("Unknown profile [%s]" % (profile,))
             return
         
         for target in targets:
@@ -151,7 +152,7 @@
                     raise jid.InvalidFormat
                 _jid = _jid.userhostJID()
             except (jid.InvalidFormat, RuntimeError):
-                info(u"invalid target ignored: %s" % (target,))
+                log.info(u"invalid target ignored: %s" % (target,))
                 continue
             process_prot = ExportCommandProtocol(self, _jid, options, profile)
             self.spawned.setdefault((_jid, profile),set()).add(process_prot)