import sys
import pygame
import logging
import sys
import pygame
import logging
+import os
+import datetime
hiddenEvents = {pygame.MOUSEMOTION:True,
pygame.MOUSEBUTTONDOWN:True,
hiddenEvents = {pygame.MOUSEMOTION:True,
pygame.MOUSEBUTTONDOWN:True,
class EventLoggerAdapter(logging.LoggerAdapter) :
FORMAT = "EVT %(ticks)-10s %(eventName)-15s %(message)s"
class EventLoggerAdapter(logging.LoggerAdapter) :
FORMAT = "EVT %(ticks)-10s %(eventName)-15s %(message)s"
def filter(self, record) :
return not hiddenEvents.has_key(record.eventType)
def filter(self, record) :
return not hiddenEvents.has_key(record.eventType)
-#logging.basicConfig(level=logging.DEBUG, stream = sys.stdout)
+logsdir = os.path.join(os.path.expandvars('$HOME'), 'minwii_logs')
+if not os.path.exists(logsdir) :
+ os.mkdir(logsdir)
+
+logfile = os.path.join(logsdir, datetime.datetime.now().strftime('%Y-%m-%d-%H_%M_%S.log'))
+logfile = open(logfile, 'w')
+
console = logging.getLogger('minwii.console')
console.setLevel(logging.DEBUG)
console = logging.getLogger('minwii.console')
console.setLevel(logging.DEBUG)
-handler = logging.StreamHandler()
+handler = logging.StreamHandler(logfile)
handler.setFormatter(logging.Formatter('APP %(message)s'))
console.addHandler(handler)
_eventLogger = logging.getLogger('minwii.events')
_eventLogger.setLevel(logging.INFO)
handler.setFormatter(logging.Formatter('APP %(message)s'))
console.addHandler(handler)
_eventLogger = logging.getLogger('minwii.events')
_eventLogger.setLevel(logging.INFO)
-_eventHandler = logging.StreamHandler()
+_eventHandler = logging.StreamHandler(logfile)
_eventFormatter = logging.Formatter(EventLoggerAdapter.FORMAT)
_eventHandler.setFormatter(_eventFormatter)
_eventLogger.addHandler(_eventHandler)
_eventLogger.addFilter(EventFilter())
eventLogger = EventLoggerAdapter(_eventLogger, {})
_eventFormatter = logging.Formatter(EventLoggerAdapter.FORMAT)
_eventHandler.setFormatter(_eventFormatter)
_eventLogger.addHandler(_eventHandler)
_eventLogger.addFilter(EventFilter())
eventLogger = EventLoggerAdapter(_eventLogger, {})
-#eventLogger = logging.getLogger('minwii.events')