FireBot/logs.py

20 lines
501 B
Python
Raw Normal View History

2023-11-05 01:37:35 +00:00
#!/usr/bin/python3
from datetime import datetime as dt
from sys import stdout, stderr
def log(
2023-11-05 03:55:26 +00:00
message: str, origin: str = "Unknown", level: str = "LOG", time: dt = "now"
2023-11-05 01:37:35 +00:00
) -> None:
if level == "EXIT":
stream = stderr
else:
stream = stdout
2023-11-05 03:55:26 +00:00
if time == "now":
dt.now()
2023-11-05 01:37:35 +00:00
if not "\n" in message:
print(f"[{level}][{origin}][{time}] {message}")
else:
for line in message.split("\n"):
print(f"[{level}][{origin}][{time}] {line}")