projects
/
minwii.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Remaniement du logging des messages de l'application : une seule info par console...
[minwii.git]
/
src
/
app
/
log.py
diff --git
a/src/app/log.py
b/src/app/log.py
index
f270b8d
..
c1e3286
100755
(executable)
--- a/
src/app/log.py
+++ b/
src/app/log.py
@@
-12,23
+12,41
@@
import sys
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 = "
EVT %(ticks)-10s %(eventName)-15
s %(message)s"
def process(self, msg, kwargs) :
def process(self, msg, kwargs) :
- pp = pprinters.get(msg.type, lambda e:
''
)
+ pp = pprinters.get(msg.type, lambda e:
str(e)
)
extra = {}
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)
-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)
_eventLogger = logging.getLogger('minwii.events')
_eventLogger.setLevel(logging.INFO)
@@
-36,10
+54,7
@@
_eventHandler = logging.StreamHandler()
_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,
- }
+#eventLogger = logging.getLogger('minwii.events')