From: pin Date: Mon, 19 Apr 2010 14:54:14 +0000 (+0000) Subject: Remaniement du logging des messages de l'application : une seule info par console... X-Git-Url: https://scm.cri.mines-paristech.fr/git/minwii.git/commitdiff_plain/778427f99b8ef872b62311cabd40a3c0e24bebde Remaniement du logging des messages de l'application : une seule info par console.info. git-svn-id: https://svn.cri.ensmp.fr/svn/minwii/trunk@152 fe552daf-6dbe-4428-90eb-1537e0879342 --- diff --git a/src/app/log.py b/src/app/log.py index f07e3d2..c1e3286 100755 --- a/src/app/log.py +++ b/src/app/log.py @@ -22,7 +22,7 @@ hiddenEvents = {pygame.MOUSEMOTION:True, class EventLoggerAdapter(logging.LoggerAdapter) : - FORMAT = "%(ticks)-10s %(eventName)-15s %(message)s" + FORMAT = "EVT %(ticks)-10s %(eventName)-15s %(message)s" def process(self, msg, kwargs) : pp = pprinters.get(msg.type, lambda e: str(e)) @@ -44,7 +44,9 @@ class EventFilter : #logging.basicConfig(level=logging.DEBUG, stream = sys.stdout) console = logging.getLogger('minwii.console') console.setLevel(logging.DEBUG) -console.addHandler(logging.StreamHandler()) +handler = logging.StreamHandler() +handler.setFormatter(logging.Formatter('APP %(message)s')) +console.addHandler(handler) _eventLogger = logging.getLogger('minwii.events') _eventLogger.setLevel(logging.INFO) diff --git a/src/app/minwii.py b/src/app/minwii.py index 4b23012..31bee79 100755 --- a/src/app/minwii.py +++ b/src/app/minwii.py @@ -83,26 +83,20 @@ class MinWii(object): app.run(home) app.close(home) - + #logging if home.exitApp : - msg = "sortie de l'application" + console.info("sortie de l'application") else : actual_wiimotes = self.WT.get_count() + console.info('chanson : %s', home.songFile) + console.info('mode : %s', home.modeSelect.value) if actual_wiimotes is None : - msg = 'chanson : %s\nmode : %s\nHID : souris' - msg = msg % (home.songFile, - home.modeSelect.value) + console.info('HID : souris') elif actual_wiimotes == 0 : - msg = 'chanson : %s\nmode : %s\nHID : souris (pas de wiimote trouvée)' - msg = msg % (home.songFile, - home.modeSelect.value) + console.info('HID : souris (pas de wiimote trouvée)') else : - msg = 'chanson : %s\nmode : %s\nHID : wiimote %d' - msg = msg % (home.songFile, - home.modeSelect.value, - home.selectedWiimote.value + 1) - - console.info(msg) + console.info('HID : wiimote %d', home.selectedWiimote.value + 1) + #--- return (home.exitApp, home.songFile, @@ -118,10 +112,13 @@ class MinWii(object): selector.stop() pygame.event.clear() EventDispatcher.reset() - if selector.selectedInstrument : - console.info('instrument : %(name)s\npreset : %(preset)d\nbank : %(bank)d\najustement octave : %(octave)d' % \ - selector.selectedInstrument) - return selector.selectedInstrument + instru = selector.selectedInstrument + if instru : + console.info('instrument : %s', instru['name']) + console.info('preset : %d', instru['preset']) + console.info('bank : %d', instru['bank']) + console.info('ajustement octave : %d', instru['octave']) + return instru def runPlayingScreen(self, songFile, playMode, instrumentDescription) : """ Lance l'écran de jeu principal avec la chanson 'songFile' dans le mode 'playMode' diff --git a/src/app/synth.py b/src/app/synth.py index 71fa126..f94358d 100755 --- a/src/app/synth.py +++ b/src/app/synth.py @@ -35,7 +35,8 @@ class Synth(FSynth) : self.start() self.fsid = self.sfload(sfPath) self._octaveAjusts = {} - console.info('démarrage du synthétiseur\nsoundfont : %s', sfPath) + console.info('démarrage du synthétiseur') + console.info('soundfont : %s', sfPath) def __del__(self) : console.info('arrêt du synthétiseur.') diff --git a/src/app/widgets/playingscreen.py b/src/app/widgets/playingscreen.py index 47898fa..1e7323c 100755 --- a/src/app/widgets/playingscreen.py +++ b/src/app/widgets/playingscreen.py @@ -94,7 +94,7 @@ class _PlayingScreenBase(pygame.sprite.LayeredDirty, EventHandlerMixin) : EventDispatcher.dispatchEvents() dirty = self.draw(pygame.display.get_surface()) pygame.display.update(dirty) - clock.tick()#FRAMERATE) + clock.tick(FRAMERATE) def stop(self) : self._running = False