From e9046a96f1edd2d52594785998d90a14d10a5803 Mon Sep 17 00:00:00 2001 From: huker667 Date: Sun, 10 May 2026 09:51:20 +0300 Subject: init commit v0.7 --- logs.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 logs.py (limited to 'logs.py') diff --git a/logs.py b/logs.py new file mode 100644 index 0000000..7947cf2 --- /dev/null +++ b/logs.py @@ -0,0 +1,31 @@ +# logs.py -- logging "lib" for qulay cli + +import time +from paths import LOG_FILE + +def _write_log(level, text, output=False): + timestamp = time.strftime("%Y-%m-%d %H:%M:%S") + line = f"{timestamp} {level[0]} {text}\n" + if output: + print(text) + with open(LOG_FILE, "a") as f: + f.write(line) + +def info(text, output=False, write=True): + if write: + _write_log("info", text, output) + else: + if output: + print(text) +def warn(text, output=False, write=True): + if write: + _write_log("warn", text, output) + else: + if output: + print(text) +def error(text, output=False, write=True): + if write: + _write_log("error", text, output) + else: + if output: + print(text) -- cgit v1.3.1