-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathlogger.py
22 lines (19 loc) · 904 Bytes
/
logger.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import sys
import os
import time
from config import getConfig
def initLogging():
global mmLogFileObject
mmLogFileObject = open(os.getcwd() + "/calculateRecipeOrder.log", "w+")
initLogging()
def log(level, process, subProcess, activity, entry):
if(int(getConfig("logLevel")) >= level):
if(activity != ""):
formattedEntry = "[" + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())) + "][" + process + "][" + subProcess + "][" + activity + "] " + entry + "\n"
elif(subProcess != ""):
formattedEntry = "[" + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())) + "][" + process + "][" + subProcess + "] " + entry + "\n"
else:
formattedEntry = "[" + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())) + "][" + process + "] " + entry + "\n"
mmLogFileObject.write(formattedEntry)
mmLogFileObject.flush()
print(formattedEntry, end="", flush=True)