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