* fix in stacktrace made it work.
* added debug config to analyze. = from now on logging.debug should be utilized to remark stuff, so final implementations can ignore such messages.
This commit is contained in:
parent
9bfdd1fb7a
commit
45c7d1e393
@ -23,6 +23,10 @@ settings = {'root_path': os.path.join(os.path.expanduser('~'),
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import logging
|
||||
logging.basicConfig(level=logging.DEBUG,
|
||||
format='%(asctime)s - %(message)s',
|
||||
datefmt='%Y-%m-%d %H:%M:%S')
|
||||
coll = LogSessionCollector(os.path.join(os.path.expanduser('~'),
|
||||
'Documents', 'My Games', 'sc'))
|
||||
coll.collect_unique()
|
||||
@ -30,7 +34,7 @@ if __name__ == '__main__':
|
||||
rex_combat = {}
|
||||
rex_game = {}
|
||||
rex_chat = {}
|
||||
LOG_GOOD = True
|
||||
LOG_GOOD = True # Log good packets.
|
||||
for logf in coll.sessions:
|
||||
logf.parse_files(['game.log', 'combat.log', 'chat.log'])
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
import logging
|
||||
|
||||
L_CMBT = 'CMBT'
|
||||
L_WARNING = 'WARNING'
|
||||
@ -56,5 +57,6 @@ class Stacktrace(Log):
|
||||
|
||||
def append(self, something):
|
||||
''' I take anything! '''
|
||||
print "EXC: %s" % something
|
||||
logging.debug( "EXC: %s" % something )
|
||||
self.message = '%s\n%s' % (self.message, something)
|
||||
return True
|
@ -22,6 +22,7 @@
|
||||
"""
|
||||
import re
|
||||
from base import Log, L_CMBT, Stacktrace
|
||||
import logging
|
||||
|
||||
class CombatLog(Log):
|
||||
__slots__ = Log.__slots__ + [ '_match_id', 'values']
|
||||
@ -215,7 +216,7 @@ class UserEvent(CombatLog):
|
||||
if line and 'earned medal' in line:
|
||||
return True
|
||||
elif line:
|
||||
print line
|
||||
logging.debug('UserEvent saw unknown line: %s' % line)
|
||||
return False
|
||||
|
||||
# Action?
|
||||
|
@ -41,7 +41,7 @@ class LogFile(LogStream):
|
||||
lines = []
|
||||
if self.has_data():
|
||||
data_lines = self.get_data(
|
||||
#).replace('\r', '\n'
|
||||
).replace('\r', '\n'
|
||||
).replace('\n\n', '\n'
|
||||
).split('\n'
|
||||
)
|
||||
|
@ -29,6 +29,7 @@
|
||||
from .base import Log
|
||||
import re
|
||||
from logs.base import Stacktrace
|
||||
import logging
|
||||
RE_SCLOG = r'^(?P<hh>\d{2,2})\:(?P<mm>\d{2,2})\:(?P<ss>\d{2,2})\.(?P<ns>\d{3,3})\s(?P<logtype>\s*[^\|\s]+\s*|\s+)\|\s(?P<log>.*)'
|
||||
R_SCLOG = re.compile(RE_SCLOG)
|
||||
|
||||
@ -87,6 +88,10 @@ class LogStream(object):
|
||||
return line
|
||||
elif line.startswith('---'):
|
||||
return None
|
||||
elif line == '' or line == '\n':
|
||||
if line == '\n':
|
||||
logging.debug('Empty Newline detected.')
|
||||
return None
|
||||
else:
|
||||
# get the timecode & logtype
|
||||
m = R_SCLOG.match(line)
|
||||
@ -96,8 +101,6 @@ class LogStream(object):
|
||||
g['logtype'] = g['logtype'].strip()
|
||||
return g
|
||||
else:
|
||||
#if line:
|
||||
# print line
|
||||
return line
|
||||
return None
|
||||
|
||||
@ -109,15 +112,19 @@ class LogStream(object):
|
||||
# Unknown Log?
|
||||
if not line:
|
||||
return
|
||||
if self._last_object is not None:
|
||||
self._last_object.unpack()
|
||||
if self._last_object.append(line):
|
||||
return
|
||||
# It might be a stacktrace. inject it./
|
||||
if Stacktrace.is_handler(o):
|
||||
o = Stacktrace(o)
|
||||
self._last_object = o
|
||||
else:
|
||||
#if isinstance(self._last_object, Stacktrace) and line.startswith('\t'):
|
||||
# logging.debug('Workaround: %s, worked: %s' % (line, self._last_object.append(line)))
|
||||
# return
|
||||
if self._last_object is not None:
|
||||
self._last_object.unpack()
|
||||
if self._last_object.append(line):
|
||||
return
|
||||
logging.debug('>> %s' % line)
|
||||
o = None
|
||||
elif isinstance(line, dict):
|
||||
# Unresolved Log.
|
||||
|
Loading…
Reference in New Issue
Block a user