diff frontends/src/quick_frontend/quick_chat.py @ 1009:d1084f7e56a5

quick_frontend: use of new logging system
author Goffi <goffi@goffi.org>
date Mon, 05 May 2014 18:58:34 +0200
parents cd02f5ef30df
children d6c3fea5ecfe
line wrap: on
line diff
--- a/frontends/src/quick_frontend/quick_chat.py	Mon May 05 18:58:34 2014 +0200
+++ b/frontends/src/quick_frontend/quick_chat.py	Mon May 05 18:58:34 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 sat.tools.jid  import JID
 from sat_frontends.quick_frontend.quick_utils import unescapePrivate
 from sat_frontends.quick_frontend.constants import Const
@@ -44,17 +45,17 @@
         """Set the users presents in the contact list for a group chat
         @param nicks: list of nicknames
         """
-        debug (_("Adding users %s to room") % nicks)
+        log.debug (_("Adding users %s to room") % nicks)
         if self.type != "group":
-            error (_("[INTERNAL] trying to set presents nicks for a non group chat window"))
+            log.error (_("[INTERNAL] trying to set presents nicks for a non group chat window"))
             raise Exception("INTERNAL ERROR") #TODO: raise proper Exception here
         self.occupants.update(nicks)
 
     def replaceUser(self, nick, show_info=True):
         """Add user if it is not in the group list"""
-        debug (_("Replacing user %s") % nick)
+        log.debug (_("Replacing user %s") % nick)
         if self.type != "group":
-            error (_("[INTERNAL] trying to replace user for a non group chat window"))
+            log.error (_("[INTERNAL] trying to replace user for a non group chat window"))
             raise Exception("INTERNAL ERROR") #TODO: raise proper Exception here
         len_before = len(self.occupants)
         self.occupants.add(nick)
@@ -63,9 +64,9 @@
 
     def removeUser(self, nick, show_info=True):
         """Remove a user from the group list"""
-        debug(_("Removing user %s") % nick)
+        log.debug(_("Removing user %s") % nick)
         if self.type != "group":
-            error (_("[INTERNAL] trying to remove user for a non group chat window"))
+            log.error (_("[INTERNAL] trying to remove user for a non group chat window"))
             raise Exception("INTERNAL ERROR") #TODO: raise proper Exception here
         self.occupants.remove(nick)
         if show_info:
@@ -80,9 +81,9 @@
 
     def changeUserNick(self, old_nick, new_nick):
         """Change nick of a user in group list"""
-        debug(_("Changing nick of user %(old_nick)s to %(new_nick)s") % {"old_nick": old_nick, "new_nick": new_nick})
+        log.debug(_("Changing nick of user %(old_nick)s to %(new_nick)s") % {"old_nick": old_nick, "new_nick": new_nick})
         if self.type != "group":
-            error (_("[INTERNAL] trying to change user nick for a non group chat window"))
+            log.error (_("[INTERNAL] trying to change user nick for a non group chat window"))
             raise Exception("INTERNAL ERROR") #TODO: raise proper Exception here
         self.removeUser(old_nick, show_info=False)
         self.replaceUser(new_nick, show_info=False)
@@ -90,14 +91,14 @@
 
     def setSubject(self, subject):
         """Set title for a group chat"""
-        debug(_("Setting subject to %s") % subject)
+        log.debug(_("Setting subject to %s") % subject)
         if self.type != "group":
-            error (_("[INTERNAL] trying to set subject for a non group chat window"))
+            log.error (_("[INTERNAL] trying to set subject for a non group chat window"))
             raise Exception("INTERNAL ERROR") #TODO: raise proper Exception here
 
     def historyPrint(self, size=20, profile='@NONE@'):
         """Print the initial history"""
-        debug (_("now we print history"))
+        log.debug (_("now we print history"))
         def onHistory(history):
             for line in history:
                 timestamp, from_jid, to_jid, message, _type, extra = line
@@ -107,7 +108,7 @@
                 self.printMessage(JID(from_jid), message, profile, timestamp)
 
         def onHistoryError(err):
-            error (_("Can't get history"))
+            log.error (_("Can't get history"))
 
         if self.target.startswith(Const.PRIVATE_PREFIX):
             target = unescapePrivate(self.target)
@@ -146,12 +147,12 @@
     def startGame(self, game_type, referee, players):
         """Configure the chat window to start a game"""
         #No need to raise an error as game are not mandatory
-        warning(_('startGame is not implemented in this frontend'))
+        log.warning(_('startGame is not implemented in this frontend'))
 
     def getGame(self, game_type):
         """Return class managing the game type"""
         #No need to raise an error as game are not mandatory
-        warning(_('getGame is not implemented in this frontend'))
+        log.warning(_('getGame is not implemented in this frontend'))
 
     def updateChatState(self, state, nick=None):
         """Set the chat state (XEP-0085) of the contact. Leave nick to None