X-Git-Url: https://svn.cri.ensmp.fr/git/minwii.git/blobdiff_plain/e6ef7fb704667d8266e6d881ff5e39be0e4188fa..f930cbccef5ed34b7b17b9e738458b048d93d1da:/src/app/log.py?ds=inline diff --git a/src/app/log.py b/src/app/log.py index b2cd407..ca10200 100755 --- a/src/app/log.py +++ b/src/app/log.py @@ -12,32 +12,47 @@ import sys import pygame import logging +hiddenEvents = {pygame.MOUSEMOTION:True, + pygame.MOUSEBUTTONDOWN:True, + pygame.MOUSEBUTTONUP:True, + TIMEOUT:True, + #COLOVER:True, + } + class EventLoggerAdapter(logging.LoggerAdapter) : - FORMAT = "%(ticks)-15s %(eventName)s %(message)s" + FORMAT = "%(ticks)-10s %(eventName)-15s %(message)s" def process(self, msg, kwargs) : pp = pprinters.get(msg.type, lambda e: '') extra = {} + extra['eventType'] = msg.type extra['eventName'] = eventNames[msg.type] extra['ticks'] = pygame.time.get_ticks() kwargs['extra']=extra return pp(msg), kwargs -#logging.basicConfig(level=logging.DEBUG, stream = sys.stdout) +class EventFilter : + + def __init__(self): + pass + + def filter(self, record) : + return not hiddenEvents.has_key(record.eventType) +#logging.basicConfig(level=logging.DEBUG, stream = sys.stdout) console = logging.getLogger('minwii.console') +console.setLevel(logging.DEBUG) +console.addHandler(logging.StreamHandler()) + _eventLogger = logging.getLogger('minwii.events') _eventLogger.setLevel(logging.INFO) _eventHandler = logging.StreamHandler() _eventFormatter = logging.Formatter(EventLoggerAdapter.FORMAT) _eventHandler.setFormatter(_eventFormatter) _eventLogger.addHandler(_eventHandler) +_eventLogger.addFilter(EventFilter()) eventLogger = EventLoggerAdapter(_eventLogger, {}) -hiddenEvents = {pygame.MOUSEMOTION:True, - TIMEOUT:True, - #COLOVER:True, - }