update personas to add Tone
This commit is contained in:
@@ -47,18 +47,36 @@ def setup_logging():
|
||||
if os.path.exists(LOG_FILE):
|
||||
with open(LOG_FILE, 'r') as f:
|
||||
lines = f.readlines()
|
||||
cutoff = datetime.now(timezone.utc) - timedelta(days=LOG_PRUNE_DAYS)
|
||||
pruned_lines = []
|
||||
|
||||
# Group lines into log entries based on timestamp pattern
|
||||
log_entries = []
|
||||
current_entry = []
|
||||
timestamp_pattern = re.compile(r'^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3}')
|
||||
|
||||
for line in lines:
|
||||
if timestamp_pattern.match(line):
|
||||
if current_entry:
|
||||
log_entries.append(''.join(current_entry))
|
||||
current_entry = [line]
|
||||
else:
|
||||
current_entry.append(line)
|
||||
|
||||
if current_entry:
|
||||
log_entries.append(''.join(current_entry))
|
||||
|
||||
cutoff = datetime.now(timezone.utc) - timedelta(days=LOG_PRUNE_DAYS)
|
||||
pruned_entries = []
|
||||
for entry in log_entries:
|
||||
try:
|
||||
timestamp = datetime.strptime(line[:19], '%Y-%m-%d %H:%M:%S').replace(tzinfo=timezone.utc)
|
||||
timestamp = datetime.strptime(entry[:19], '%Y-%m-%d %H:%M:%S').replace(tzinfo=timezone.utc)
|
||||
if timestamp > cutoff:
|
||||
pruned_lines.append(line)
|
||||
pruned_entries.append(entry)
|
||||
except ValueError:
|
||||
logging.warning(f"Skipping malformed log line: {line.strip()[:50]}...")
|
||||
logging.warning(f"Skipping malformed log entry (no timestamp): {entry[:50]}...")
|
||||
continue
|
||||
|
||||
with open(LOG_FILE, 'w') as f:
|
||||
f.writelines(pruned_lines)
|
||||
f.writelines(pruned_entries)
|
||||
|
||||
logging.basicConfig(
|
||||
filename=LOG_FILE,
|
||||
|
||||
Reference in New Issue
Block a user