diff browser_side/card_game.py @ 439:d52f529a6d42

browser side: use of new log system (first draft): - configuration is hardcoded in libervia.py, it will change in the (hopefuly) near future - log level is DEBUG for the moment, will be changed to INFO when configuration will not be hardcoded anymore - the basic log backend is used, in the future, a console.debug/info/etc should be used instead. A log widget which HTML colors is also an option
author Goffi <goffi@goffi.org>
date Thu, 08 May 2014 17:21:34 +0200
parents b96b8b666d17
children
line wrap: on
line diff
--- a/browser_side/card_game.py	Thu May 08 17:21:30 2014 +0200
+++ b/browser_side/card_game.py	Thu May 08 17:21:34 2014 +0200
@@ -18,6 +18,8 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 import pyjd  # this is dummy in pyjs
+from sat.core.log import getLogger
+log = getLogger(__name__)
 from pyjamas.ui.AbsolutePanel import AbsolutePanel
 from pyjamas.ui.DockPanel import DockPanel
 from pyjamas.ui.SimplePanel import SimplePanel
@@ -172,11 +174,11 @@
     def loadCards(self):
         """Load all the cards in memory"""
         def _getTarotCardsPathsCb(paths):
-            print "_getTarotCardsPathsCb"
+            log.debug("_getTarotCardsPathsCb")
             for file_ in paths:
-                print "path:", file_
+                log.debug("path:", file_)
                 card = CardWidget(self, file_)
-                print "card:", card
+                log.debug("card:", card)
                 self.cards[(card.suit, card.value)] = card
                 self.deck.append(card)
             self._parent.host.bridge.call('tarotGameReady', None, self.player_nick, self.referee)
@@ -277,7 +279,7 @@
         elif phase == "ecart":
             self.state = "ecart"
         else:
-            print 'INTERNAL ERROR: unmanaged game phase'
+            log.error("INTERNAL ERROR: unmanaged game phase") # FIXME: raise an exception here
 
         for suit, value in played_cards:
             self.hand.append(self.cards[(suit, value)])
@@ -317,15 +319,15 @@
         for location in ['top', 'left', 'bottom', 'right']:
             if getattr(self, '%s_nick' % location) == nick:
                 return location
-        print ("ERROR: This line should not be reached")
+        log.error("This line should not be reached")
 
     def tarotGameCardsPlayed(self, player, cards):
         """A card has been played by player"""
         if not len(cards):
-            print ("WARNING: cards should not be empty")
+            log.warning("cards should not be empty")
             return
         if len(cards) > 1:
-            print ("ERROR: can't manage several cards played")
+            log.error("can't manage several cards played")
         if self.to_show:
             self.to_show = []
             self.updateToShow()