You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

27 lines
872 B

# -*- coding: utf-8 -*-
"""票 06 实验判别:crm-app.log 中实验商机 id 附近的 UPDATE SQL。"""
import io, sys
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
txt = open(r'e:/code/crm-backend-matt/logs/crm-app.log', encoding='utf-8', errors='replace').read()
oid = '749196675649634304'
print('total len =', len(txt))
# 找该 id 出现的上下文(UPDATE 语句)
import re
idxs = [m.start() for m in re.finditer(oid, txt)]
print('occurrences =', len(idxs))
shown = 0
for i in idxs:
seg = txt[max(0, i - 400):i + 300]
if 'UPDATE' in seg.upper():
print('=' * 80)
print(seg)
shown += 1
if shown >= 3:
break
if shown == 0:
print('--- no UPDATE context found; last 3 occurrence contexts ---')
for i in idxs[-3:]:
print('=' * 80)
print(txt[max(0, i - 400):i + 300])