Mercurial > libervia-backend
diff src/plugins/plugin_misc_quiz.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 | 1a759096ccbd |
children | 83127a4c89ce |
line wrap: on
line diff
--- a/src/plugins/plugin_misc_quiz.py Sat Apr 19 16:48:26 2014 +0200 +++ b/src/plugins/plugin_misc_quiz.py Sat Apr 19 19:19:19 2014 +0200 @@ -19,11 +19,12 @@ from sat.core.i18n import _ from sat.core.constants import Const as C -from logging import debug, info, warning, error +from sat.core.log import getLogger +log = getLogger(__name__) from twisted.words.xish import domish from twisted.internet import protocol, defer, threads, reactor from twisted.words.protocols.jabber import client, jid, xmlstream -from twisted.words.protocols.jabber import error as jab_error +from twisted.words.protocols import jabber from twisted.words.protocols.jabber.xmlstream import IQ import random @@ -54,7 +55,7 @@ self.__class__ = type(self.__class__.__name__, (self.__class__, RoomGame, object), {}) def __init__(self, host): - info(_("Plugin Quiz initialization")) + log.info(_("Plugin Quiz initialization")) self.inheritFromRoomGame(host) RoomGame._init_(self, host, PLUGIN_INFO, (NS_QG, QG_TAG), game_init={'stage': None}, player_init={'score': 0}) host.bridge.addMethod("quizGameLaunch", ".plugin", in_sign='asss', out_sign='', method=self.prepareRoom) # args: players, room_jid, profile @@ -180,9 +181,9 @@ """Called when a player give an answer""" profile = self.host.memory.getProfileName(profile_key) if not profile: - error(_("profile %s is unknown") % profile_key) + log.error(_("profile %s is unknown") % profile_key) return - debug('new player answer (%(profile)s): %(answer)s' % {'profile': profile, 'answer': answer}) + log.debug('new player answer (%(profile)s): %(answer)s' % {'profile': profile, 'answer': answer}) mess = self.createGameElt(jid.JID(referee)) answer_elt = mess.firstChildElement().addElement('player_answer') answer_elt['player'] = player @@ -280,7 +281,7 @@ status = self.games[room_jid.userhost()]['status'] nb_players = len(self.games[room_jid.userhost()]['players']) status[player] = 'ready' - debug(_('Player %(player)s is ready to start [status: %(status)s]') % {'player': player, 'status': status}) + log.debug(_('Player %(player)s is ready to start [status: %(status)s]') % {'player': player, 'status': status}) if status.values().count('ready') == nb_players: # everybody is ready, we can start the game self.newGame(room_jid, profile) @@ -328,4 +329,4 @@ self.host.bridge.quizGameTimerRestarted(room_jid.userhost(), int(elt['time_left']), profile) else: - error(_('Unmanaged game element: %s') % elt.name) + log.error(_('Unmanaged game element: %s') % elt.name)