forked from Firepup650/FireBot
19 lines
545 B
Python
19 lines
545 B
Python
#!/usr/bin/python3
|
|
from datetime import datetime as dt
|
|
from sys import stdout, stderr
|
|
|
|
|
|
def log(
|
|
message: str, origin: str = "Unknown", level: str = "LOG", time: dt = "now"
|
|
) -> None:
|
|
if level in ["EXIT", "CRASH"]:
|
|
stream = stderr
|
|
else:
|
|
stream = stdout
|
|
if time == "now":
|
|
time = dt.now()
|
|
if not "\n" in message:
|
|
print(f"[{level}][{origin}][{time}] {message}", file=stream)
|
|
else:
|
|
for line in message.split("\n"):
|
|
print(f"[{level}][{origin}][{time}] {line}", file=stream)
|