summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
49c528b)
import types
import pygame
from StringIO import StringIO
import types
import pygame
from StringIO import StringIO
-from log import console, eventLogger, hiddenEvents, pprinters
+from log import console, eventLogger
class _EventDispatcher :
def __init__(self) :
class _EventDispatcher :
def __init__(self) :
def dispatchEvents(self) :
events = pygame.event.get()
for event in events :
def dispatchEvents(self) :
events = pygame.event.get()
for event in events :
+ eventLogger.info(event)
listeners = self.registry.get(event.type, {})
listeners = self.registry.get(event.type, {})
- if not hiddenEvents.has_key(event.type):
- eventLogger.info(event)
for listener in listeners.keys() :
listener(event)
for listener in listeners.keys() :
listener(event)
import pygame
import logging
import pygame
import logging
+hiddenEvents = {pygame.MOUSEMOTION:True,
+ pygame.MOUSEBUTTONDOWN:True,
+ pygame.MOUSEBUTTONUP:True,
+ TIMEOUT:True,
+ #COLOVER:True,
+ }
+
class EventLoggerAdapter(logging.LoggerAdapter) :
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 = {}
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
extra['eventName'] = eventNames[msg.type]
extra['ticks'] = pygame.time.get_ticks()
kwargs['extra']=extra
return pp(msg), kwargs
+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)
#logging.basicConfig(level=logging.DEBUG, stream = sys.stdout)
console = logging.getLogger('minwii.console')
console.setLevel(logging.DEBUG)
_eventFormatter = logging.Formatter(EventLoggerAdapter.FORMAT)
_eventHandler.setFormatter(_eventFormatter)
_eventLogger.addHandler(_eventHandler)
_eventFormatter = logging.Formatter(EventLoggerAdapter.FORMAT)
_eventHandler.setFormatter(_eventFormatter)
_eventLogger.addHandler(_eventHandler)
+_eventLogger.addFilter(EventFilter())
eventLogger = EventLoggerAdapter(_eventLogger, {})
eventLogger = EventLoggerAdapter(_eventLogger, {})
-hiddenEvents = {pygame.MOUSEMOTION:True,
- TIMEOUT:True,
- #COLOVER:True,
- }