Python
import datetime
from collections import namedtuple
Record = namedtuple( 'Record', 'file,level,number,datetime,assembly,class,method,message' )
def block_iter( theFile ):
file_iter= iter(theFile)
while True:
items= [ next(file_iter) for x in range(9) ]
if not items: break
yield items
def record_iter( blocks ):
for items in blocks:
file, level, number = items[0].split(":")
dt = datetime.datetime.strptime( items[1], "%m/%d/%Y %H:%M:%S %p" )
_, _, asm = items[2].partition(":")
_, _, cls = items[3].partition(":")
_, _, mth = items[4].partition(":")
txt = "".join( items[5:] )
yield Record( file, level, number, dt, asm, cls, mth, txt )
with open( "someapp.log", "r" ) as source:
for log in record_iter( block_iter( source ) ):
print log
Нечто подобное может помочь вам начать.