1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00

Better logging

This commit is contained in:
Krateng 2019-03-10 18:14:50 +01:00
parent b9e754a6bb
commit 52cf14de7e
2 changed files with 5 additions and 1 deletions

View File

@ -69,3 +69,5 @@ If you didn't install Maloja from the package (and therefore don't have it in `/
maloja restart maloja restart
maloja start maloja start
maloja update maloja update
The `update` command will always fetch the latest version, while packages are only offered for release versions.

View File

@ -4,6 +4,7 @@ import hashlib
from threading import Thread from threading import Thread
import pickle import pickle
import urllib import urllib
import datetime
### TSV files ### TSV files
@ -160,11 +161,12 @@ def cleandict(d):
def log(msg): def log(msg):
import inspect import inspect
now = datetime.datetime.utcnow().strftime("%Y/%m/%d %H:%M:%S")
module = inspect.getmodule(inspect.stack()[1][0]).__name__ module = inspect.getmodule(inspect.stack()[1][0]).__name__
if module == "__main__": module = "mainserver" if module == "__main__": module = "mainserver"
print("[" + module + "] " + msg) print("[" + module + "] " + msg)
with open("logs/" + module + ".log","a") as logfile: with open("logs/" + module + ".log","a") as logfile:
logfile.write(msg + "\n") logfile.write(now + " " + msg + "\n")