add support for multiple log-files
This commit is contained in:
parent
92518aed55
commit
b4456d9080
10
tsstats.py
10
tsstats.py
|
@ -1,5 +1,6 @@
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
import glob
|
||||||
import json
|
import json
|
||||||
import configparser
|
import configparser
|
||||||
from os.path import exists
|
from os.path import exists
|
||||||
|
@ -135,10 +136,13 @@ def check_client(clid, nick):
|
||||||
clients[clid] = {}
|
clients[clid] = {}
|
||||||
clients[clid]['nick'] = nick
|
clients[clid]['nick'] = nick
|
||||||
|
|
||||||
|
log_files = [file_name for file_name in glob.glob(log_path)]
|
||||||
with open(log_path, 'r') as f:
|
log_lines = []
|
||||||
|
for log_file in log_files:
|
||||||
|
for line in open(log_file, 'r'):
|
||||||
|
log_lines.append(line)
|
||||||
today = datetime.utcnow()
|
today = datetime.utcnow()
|
||||||
for line in f:
|
for line in log_lines:
|
||||||
parts = line.split('|')
|
parts = line.split('|')
|
||||||
logdatetime = datetime.strptime(parts[0], '%Y-%m-%d %H:%M:%S.%f')
|
logdatetime = datetime.strptime(parts[0], '%Y-%m-%d %H:%M:%S.%f')
|
||||||
sid = int(parts[3].strip())
|
sid = int(parts[3].strip())
|
||||||
|
|
Loading…
Reference in New Issue