ripensamenti sui file di configurazione, il logger legge un file
separato
This commit is contained in:
@@ -3,17 +3,21 @@ Created on 2 nov 2019
|
||||
|
||||
@author: Emanuele Trabattoni
|
||||
'''
|
||||
import sys, os
|
||||
import sys
|
||||
import json
|
||||
import logging
|
||||
import colorama
|
||||
from bananaSPLIT.main import fp
|
||||
|
||||
class fancyLogger(object):
|
||||
'''
|
||||
Colorizza il logger di python, per un' esperienza stile willy wonka
|
||||
'''
|
||||
def __init__(self, name="Logger", consoleLog=True, fileLog=True):
|
||||
settings = json.load(open(os.getcwd()+r"\libbananasplit\testEN.json"))["logger"]
|
||||
def __init__(self, filepath=None, name="Logger", consoleLog=True, fileLog=False):
|
||||
try:
|
||||
with open(filepath, 'r') as fp:
|
||||
settings = json.load(fp)
|
||||
fp.close()
|
||||
colorama.init(convert=True)
|
||||
self.LRED = colorama.Fore.LIGHTRED_EX
|
||||
self.RED = colorama.Fore.RED
|
||||
@@ -43,6 +47,8 @@ class fancyLogger(object):
|
||||
cl.setLevel(logging.DEBUG)
|
||||
cl.setFormatter(FORMATTER)
|
||||
self.LOGGER.addHandler(cl)
|
||||
except IOError as e:
|
||||
print("Impossibile caricare la configurazione del logger: [{}]".format(e))
|
||||
pass
|
||||
|
||||
def debug(self, msg="Undefined Debug"):
|
||||
|
||||
5
bananaSPLIT/libbananasplit/loggerconf.json
Normal file
5
bananaSPLIT/libbananasplit/loggerconf.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"logFile": "D:\\Test\\bananaSPLIT.log",
|
||||
"logFormat": "%(asctime)s|%(levelname)-8s| %(message)-50s",
|
||||
"logTimeFormat": "%m-%d %H:%M:%S"
|
||||
}
|
||||
@@ -1,10 +1,5 @@
|
||||
{
|
||||
"version": "v1.1a",
|
||||
"logger": {
|
||||
"logFile": "D:\\Test\\bananaSPLIT.log",
|
||||
"logFormat": "%(asctime)s|%(levelname)-8s| %(message)-50s",
|
||||
"logTimeFormat": "%m-%d %H:%M:%S"
|
||||
},
|
||||
"splitter": {
|
||||
"name": "",
|
||||
"paths": {
|
||||
|
||||
Reference in New Issue
Block a user