Update generate_log.py

This commit is contained in:
Aryan Singh committed 2026-09-13 00:12:56 -05:00
1 parent 18ca01ed6b
commit 90931b2d75
1 file changed
+21 -6
+21 -6
View File
@@ -21,12 +21,27 @@ log_messages = [
"System update installed.", "System update installed.",
] ]
#first 11 in this log file should be extact order in log_messages list and then random from there open(machine_log_file, "w").close()
for i in range(num_lines): for i in range(num_lines):
if i < 11: #on all
log_entry = f"[{machine_num}-{i}] [{log_level[i % len(log_level)]}] {log_messages[i]}\n" if i == 0:
log_entry = f"[{machine_num}-{i}] [INFO] TEST_ALL\n"
#unique
elif i == 1:
log_entry = f"[{machine_num}-{i}] [DEBUG] TEST_UNIQUE\n"
#on some
elif i == 2 and machine_num in [1, 3, 5, 7, 9]:
log_entry = f"[{machine_num}-{i}] [ERROR] TEST_SOME\n"
elif 3 <= i < 13:
log_entry = f"[{machine_num}-{i}] [INFO] TEST_MEDIUM\n"
else: else:
log_entry = f"[{machine_num}-{i}] [{log_level[random.randint(0, len(log_level) - 1)]}] {log_messages[random.randint(0, len(log_messages) - 1)]}\n" log_entry = f"[{machine_num}-{i}] [{random.choice(log_level)}] {random.choice(log_messages)}\n"
with open(machine_log_file, "a") as file:
file.write(log_entry) with open(machine_log_file, "a") as f:
f.write(log_entry)