This commit is contained in:
Gabor Körber 2017-05-24 12:59:12 +02:00
parent 9e16e1786c
commit 3268cd9982
6 changed files with 110 additions and 76 deletions

View File

@ -56,8 +56,10 @@ class Log(object):
# datetime.time(hour[, minute[, second[, microsecond[, tzinfo]]]]) # datetime.time(hour[, minute[, second[, microsecond[, tzinfo]]]])
_time = datetime.time( int(self.values.get('hh')), _time = datetime.time( int(self.values.get('hh')),
int(self.values.get('mm')), int(self.values.get('mm')),
int(self.values.get('ss'), 0), int(self.values.get('ss', 0)),
int(self.values.get('ns', 0)) ) int(self.values.get('ns', 0)) )
self._timestamp = _time
return _time
def unpack(self, force=False): def unpack(self, force=False):
''' unpacks this log from its data and saves values ''' ''' unpacks this log from its data and saves values '''

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from logs.base import Log, L_WARNING, Stacktrace from .base import Log, L_WARNING, Stacktrace
import re import re
""" """
Responsible for Chat Log. Responsible for Chat Log.

View File

@ -4,21 +4,8 @@
This is the most important part for dealing with actual statistics, since every action taken This is the most important part for dealing with actual statistics, since every action taken
in a combat instance gets logged here. in a combat instance gets logged here.
------------------------------------
Note:
All logs start with something like
23:53:29.137 | LOGDATA
LOGDATA can be quite different depending on the logfile.
other forms encountered:
23:54:00.600 WARNING|
combat logs:
01:04:38.805 CMBT |
""" """
import re import re
from .base import Log, L_CMBT, Stacktrace from .base import Log, L_CMBT, Stacktrace
import logging import logging
@ -409,3 +396,20 @@ COMBAT_LOGS = [ Apply, Damage, Spawn, Spell, Reward, Participant, Rocket, Heal,
Stacktrace, Stacktrace,
] ]
"""
------------------------------------
Note:
All logs start with something like
23:53:29.137 | LOGDATA
LOGDATA can be quite different depending on the logfile.
other forms encountered:
23:54:00.600 WARNING|
combat logs:
01:04:38.805 CMBT |
"""

View File

@ -1,56 +1,18 @@
#!/usr/bin/python #!/usr/bin/python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from logs.base import Log, L_WARNING, Stacktrace
import re
""" """
This deals with the Game.Log file This deals with the Game.Log file
This file records lots of junk, but is needed to establish actions taken between combat sessions, This file records lots of junk, but is needed to establish actions taken between combat sessions,
or retrieve more detailed information about running instances. or retrieve more detailed information about running instances.
It is also the typical place for a Stacktrace to happen. It is also the typical place for a Stacktrace to happen.
--------------------------------------
Interesting Lines:
23:16:27.427 | Steam initialized appId 212070, userSteamID 1|1|4c5a01, userName 'G4bOrg'
23:16:36.214 | ====== starting level: 'levels/mainmenu/mainmenu' ======
23:16:38.822 | ====== level started: 'levels/mainmenu/mainmenu' success ======
23:16:44.251 | ====== starting level: 'levels\mainmenu\mm_empire' ======
23:16:46.464 | ====== level started: 'levels\mainmenu\mm_empire' success ======
--- Date: 2014-07-18 (Fri Jul 2014) Mitteleuropäische Sommerzeit UTC+01:00
23:55:55.517 | MasterServerSession: connect to dedicated server, session 6777304, at addr 159.253.138.162|35005
23:55:55.543 | client: start connecting to 159.253.138.162|35005...
23:55:55.683 | client: connected to 159.253.138.162|35005, setting up session...
23:55:55.886 | client: ADD_PLAYER 0 (OregyenDuero [OWL], 00039C86) status 6 team 1 group 1178422
23:55:55.886 | client: ADD_PLAYER 1 (R0gue, 0012768A) status 6 team 2 group 1178451
23:55:55.886 | client: ADD_PLAYER 2 (g4borg [OWL], 0003A848) status 1 team 1 group 1178422
23:55:55.886 | client: ADD_PLAYER 3 (WladTepes, 001210D8) status 6 team 1
23:55:55.886 | client: ADD_PLAYER 4 (oberus [], 000FE9B2) status 6 team 2
23:55:55.886 | client: ADD_PLAYER 5 (TheGuns58, 00121C58) status 6 team 1
23:55:55.886 | client: ADD_PLAYER 6 (Belleraphon, 0004C744) status 2 team 2
23:55:55.886 | client: ADD_PLAYER 7 (TopoL, 00007E1F) status 6 team 1
23:55:55.886 | client: ADD_PLAYER 8 (unicoimbraPT, 000C4FAC) status 6 team 2
23:55:55.886 | client: ADD_PLAYER 9 (AeroBobik [], 00082047) status 6 team 1
23:55:55.886 | client: ADD_PLAYER 10 (Samson4321 [], 000B93AF) status 6 team 2
23:55:55.886 | client: ADD_PLAYER 11 (nol [], 00069165) status 6 team 1
23:55:55.886 | client: ADD_PLAYER 12 (Pudwoppa, 000334A4) status 2 team 2
23:55:55.886 | client: ADD_PLAYER 13 (IgorMad [], 000D2AF3) status 6 team 1
23:55:55.886 | client: ADD_PLAYER 14 (YokaI, 000F1CC9) status 6 team 2
23:55:55.886 | client: ADD_PLAYER 15 (MrAnyKey [], 0012246C) status 6 team 2 group 1178451
23:55:55.886 | client: ADD_PLAYER 30 ((bot)David, 00000000) status 4 team 1
23:55:55.886 | client: ADD_PLAYER 31 ((bot)George, 00000000) status 4 team 2
23:55:55.886 | client: server assigned id 2
23:55:55.886 | client: got level load message 's1340_thar_aliendebris13'
23:55:55.889 | reset d3d device
23:55:56.487 | ReplayManager: stopping activity due to map change
23:55:56.576 | ====== starting level: 'levels\area2\s1340_thar_aliendebris13' KingOfTheHill client ======
""" """
from .base import Log, L_WARNING, Stacktrace
import re
import logging
trash_log = logging.getLogger('trash_log')
class GameLog(Log): class GameLog(Log):
__slots__ = Log.__slots__ __slots__ = Log.__slots__
@classmethod @classmethod
@ -90,16 +52,14 @@ class GameLog(Log):
self.trash = False self.trash = False
return True return True
# unknown? # unknown?
trash_log.info('%s\t\t%s' % (self.__class__.__name__, self.values.get('log', '')))
self.trash = True self.trash = True
def explain(self): def explain(self):
''' returns a String readable by humans explaining this Log ''' ''' returns a String readable by humans explaining this Log '''
return self.values.get('log', 'Unknown Game Log') return self.values.get('log', 'Unknown Game Log')
class WarningLog(Log): class WarningLog(Log):
# has no slots, always trash.
trash = True
@classmethod @classmethod
def is_handler(cls, log): def is_handler(cls, log):
if log.get('logtype', None) == L_WARNING: if log.get('logtype', None) == L_WARNING:
@ -107,6 +67,7 @@ class WarningLog(Log):
return False return False
def __init__(self, values=None): def __init__(self, values=None):
super(WarningLog, self).__init__()
self.trash = True self.trash = True
######################################################################################################## ########################################################################################################
@ -203,10 +164,53 @@ class LevelStarted(GameLog):
GAME_LOGS = [#SteamInitialization, GAME_LOGS = [SteamInitialization,
MasterServerSession, MasterServerSession,
ClientInfo, ClientInfo,
StartingLevel, StartingLevel,
#LevelStarted, LevelStarted,
Stacktrace, Stacktrace,
] ]
"""
--------------------------------------
Interesting Lines:
23:16:27.427 | Steam initialized appId 212070, userSteamID 1|1|4c5a01, userName 'G4bOrg'
23:16:36.214 | ====== starting level: 'levels/mainmenu/mainmenu' ======
23:16:38.822 | ====== level started: 'levels/mainmenu/mainmenu' success ======
23:16:44.251 | ====== starting level: 'levels\mainmenu\mm_empire' ======
23:16:46.464 | ====== level started: 'levels\mainmenu\mm_empire' success ======
--- Date: 2014-07-18 (Fri Jul 2014) Mitteleuropäische Sommerzeit UTC+01:00
23:55:55.517 | MasterServerSession: connect to dedicated server, session 6777304, at addr 159.253.138.162|35005
23:55:55.543 | client: start connecting to 159.253.138.162|35005...
23:55:55.683 | client: connected to 159.253.138.162|35005, setting up session...
23:55:55.886 | client: ADD_PLAYER 0 (OregyenDuero [OWL], 00039C86) status 6 team 1 group 1178422
23:55:55.886 | client: ADD_PLAYER 1 (R0gue, 0012768A) status 6 team 2 group 1178451
23:55:55.886 | client: ADD_PLAYER 2 (g4borg [OWL], 0003A848) status 1 team 1 group 1178422
23:55:55.886 | client: ADD_PLAYER 3 (WladTepes, 001210D8) status 6 team 1
23:55:55.886 | client: ADD_PLAYER 4 (oberus [], 000FE9B2) status 6 team 2
23:55:55.886 | client: ADD_PLAYER 5 (TheGuns58, 00121C58) status 6 team 1
23:55:55.886 | client: ADD_PLAYER 6 (Belleraphon, 0004C744) status 2 team 2
23:55:55.886 | client: ADD_PLAYER 7 (TopoL, 00007E1F) status 6 team 1
23:55:55.886 | client: ADD_PLAYER 8 (unicoimbraPT, 000C4FAC) status 6 team 2
23:55:55.886 | client: ADD_PLAYER 9 (AeroBobik [], 00082047) status 6 team 1
23:55:55.886 | client: ADD_PLAYER 10 (Samson4321 [], 000B93AF) status 6 team 2
23:55:55.886 | client: ADD_PLAYER 11 (nol [], 00069165) status 6 team 1
23:55:55.886 | client: ADD_PLAYER 12 (Pudwoppa, 000334A4) status 2 team 2
23:55:55.886 | client: ADD_PLAYER 13 (IgorMad [], 000D2AF3) status 6 team 1
23:55:55.886 | client: ADD_PLAYER 14 (YokaI, 000F1CC9) status 6 team 2
23:55:55.886 | client: ADD_PLAYER 15 (MrAnyKey [], 0012246C) status 6 team 2 group 1178451
23:55:55.886 | client: ADD_PLAYER 30 ((bot)David, 00000000) status 4 team 1
23:55:55.886 | client: ADD_PLAYER 31 ((bot)George, 00000000) status 4 team 2
23:55:55.886 | client: server assigned id 2
23:55:55.886 | client: got level load message 's1340_thar_aliendebris13'
23:55:55.889 | reset d3d device
23:55:56.487 | ReplayManager: stopping activity due to map change
23:55:56.576 | ====== starting level: 'levels\area2\s1340_thar_aliendebris13' KingOfTheHill client ======
"""

View File

@ -32,7 +32,7 @@ class CombatLogFile(LogFile):
return line return line
class GameLogFile(LogFile): class GameLogFile(LogFile):
''' Game Log ''' ''' Game Log '''
def resolve(self, line): def resolve(self, line):
for klass in GAME_LOGS: for klass in GAME_LOGS:
if klass.is_handler(line): if klass.is_handler(line):

View File

@ -21,16 +21,40 @@ if __name__ == '__main__':
print (logf.idstr) print (logf.idstr)
logf.parse_files(['game.log', 'combat.log']) logf.parse_files(['game.log', 'combat.log'])
if logf.combat_log:
print(('length combat log ', len(logf.combat_log.lines)))
if logf.game_log:
print(('length game log ', len(logf.game_log.lines)))
print(battle_factory(logf))
print ("Cleaning.") battles = battle_factory(logf)
if len(battles) < 1:
# skip this
continue
for battle in battles:
print(battle.level)
combat_log_lines, game_log_lines = (0, 0)
if logf.combat_log:
combat_log_lines = len(logf.combat_log.lines)
if logf.game_log:
game_log_lines = len(logf.game_log.lines)
preserved = 0
for line in logf.game_log.lines:
if isinstance(line, dict):
continue
if not line.trash:
preserved += 1
print("Actually %s lines should be preserved in game.log on clean..." % preserved)
logf.clean() logf.clean()
if logf.combat_log: if logf.combat_log:
print(('length combat log ', len(logf.combat_log.lines))) print('combat.log: %s lines were eliminated during cleaning (%s -> %s)' % ( combat_log_lines - len(logf.combat_log.lines),
combat_log_lines,
len(logf.combat_log.lines),
) )
if logf.game_log: if logf.game_log:
print(('length game log ', len(logf.game_log.lines))) print('game.log: %s lines were eliminated during cleaning (%s -> %s)' % ( game_log_lines - len(logf.game_log.lines),
game_log_lines,
len(logf.game_log.lines),
) )