b2cd407ecc0ef0306710f317232a1dd42952cd90
1 # -*- coding: utf-8 -*-
3 utilitaires pour tracer l'activité de miiwii
9 from events
import TIMEOUT
, COLOVER
, eventNames
10 from event_pprinters
import pprinters
16 class EventLoggerAdapter(logging
.LoggerAdapter
) :
18 FORMAT
= "%(ticks)-15s %(eventName)s %(message)s"
20 def process(self
, msg
, kwargs
) :
21 pp
= pprinters
.get(msg
.type, lambda e
: '')
23 extra
['eventName'] = eventNames
[msg
.type]
24 extra
['ticks'] = pygame
.time
.get_ticks()
26 return pp(msg
), kwargs
28 #logging.basicConfig(level=logging.DEBUG, stream = sys.stdout)
30 console
= logging
.getLogger('minwii.console')
31 _eventLogger
= logging
.getLogger('minwii.events')
32 _eventLogger
.setLevel(logging
.INFO
)
33 _eventHandler
= logging
.StreamHandler()
34 _eventFormatter
= logging
.Formatter(EventLoggerAdapter
.FORMAT
)
35 _eventHandler
.setFormatter(_eventFormatter
)
36 _eventLogger
.addHandler(_eventHandler
)
38 eventLogger
= EventLoggerAdapter(_eventLogger
, {})
40 hiddenEvents
= {pygame
.MOUSEMOTION
:True,