35 lines
744 B
Python
Executable File
35 lines
744 B
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
Simple log tail for Arena Battle Server
|
|
"""
|
|
|
|
import sys
|
|
import time
|
|
from pathlib import Path
|
|
|
|
LOG_FILE = Path(__file__).parent.parent / "logs" / "server.log"
|
|
|
|
def tail_log():
|
|
if not LOG_FILE.exists():
|
|
print(f"Log file not found: {LOG_FILE}")
|
|
print("Start the server first.")
|
|
sys.exit(1)
|
|
|
|
print(f"=== Tail {LOG_FILE} (Ctrl+C to stop) ===")
|
|
|
|
with open(LOG_FILE, "r") as f:
|
|
f.seek(0, 2)
|
|
|
|
while True:
|
|
line = f.readline()
|
|
if line:
|
|
print(line.strip())
|
|
else:
|
|
time.sleep(0.5)
|
|
|
|
if __name__ == "__main__":
|
|
try:
|
|
tail_log()
|
|
except KeyboardInterrupt:
|
|
print("\nStopped")
|