31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
import random
|
|
|
|
machine_num = int(sys.argv[1])
|
|
machine_log_file = f"machine.{machine_num}.test.log"
|
|
num_lines = int(sys.argv[2])
|
|
|
|
log_level = ["TRACE", "DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL", "AUDIT"]
|
|
|
|
log_messages = [
|
|
"User logged in successfully.",
|
|
"Database connection established.",
|
|
"File not found: config.yaml",
|
|
"Memory usage is high.",
|
|
"Disk space is running low.",
|
|
"Unauthorized access attempt detected.",
|
|
"Configuration file updated.",
|
|
"Service restarted successfully.",
|
|
"Network latency is above threshold.",
|
|
"Scheduled backup completed.",
|
|
"System update installed.",
|
|
]
|
|
|
|
#first 11 in this log file should be extact order in log_messages list and then random from there
|
|
|
|
for i in range(num_lines):
|
|
if i < 11:
|
|
log_entry = f"[{machine_num}-{i}] [{log_level[i % len(log_level)]}] {log_messages[i]}\n"
|
|
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"
|
|
with open(machine_log_file, "a") as file:
|
|
file.write(log_entry) |