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