mirror of
https://gitlab.os-k.eu/neox/CNIRevelator.git
synced 2023-08-25 14:03:10 +02:00
Update logger.py
This commit is contained in:
parent
27e50768a8
commit
8cbec148da
@ -22,40 +22,43 @@
|
|||||||
* along with CNIRevelator. If not, see <https:*www.gnu.org/licenses/>. *
|
* along with CNIRevelator. If not, see <https:*www.gnu.org/licenses/>. *
|
||||||
********************************************************************************
|
********************************************************************************
|
||||||
"""
|
"""
|
||||||
## The logging class
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import globs
|
import globs
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
## The logging class
|
||||||
class NewLoggingSystem:
|
class NewLoggingSystem:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
||||||
# Deleting the error log
|
# Deleting the error log
|
||||||
try:
|
try:
|
||||||
os.remove(globs.CNIRFolder + '\\error.log') # The deletion does not working
|
os.remove(globs.CNIRFolder + '\\error.log') # The deletion does not working
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
#print(str(e) + " : " + str(globs.CNIRFolder + '\\error.log'))
|
#print(str(e) + " : " + str(globs.CNIRFolder + '\\error.log'))
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Create new logging handle
|
# Create new logging handle
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
logger.setLevel(logging.INFO) # To make sure we can have a debug channel
|
logger.setLevel(logging.INFO) # To make sure we can have a debug channel
|
||||||
|
|
||||||
# Create channels
|
# Create channels
|
||||||
formatter = logging.Formatter('[ %(module)s/%(funcName)s ] %(asctime)s :: %(levelname)s :: %(message)s')
|
formatter = logging.Formatter("\n[ %(module)s/%(funcName)s ] %(asctime)s :: %(levelname)s :: %(message)s")
|
||||||
error_handler = logging.FileHandler((globs.CNIRFolder + '\\error.log'), mode='w', encoding='utf-8', delay=True)
|
error_handler = logging.FileHandler((globs.CNIRFolder + '\\error.log'), mode='w', encoding='utf-8', delay=True)
|
||||||
info_handler = logging.FileHandler((globs.CNIRFolder + '\\launcher.log'), mode='w', encoding='utf-8')
|
info_handler = logging.FileHandler((globs.CNIRFolder + '\\launcher.log'), mode='w', encoding='utf-8')
|
||||||
|
|
||||||
error_handler.setLevel(logging.ERROR)
|
error_handler.setLevel(logging.ERROR)
|
||||||
error_handler.setFormatter(formatter)
|
error_handler.setFormatter(formatter)
|
||||||
logger.addHandler(error_handler)
|
logger.addHandler(error_handler)
|
||||||
|
|
||||||
info_handler.setLevel(logging.DEBUG)
|
info_handler.setLevel(logging.DEBUG)
|
||||||
info_handler.setFormatter(formatter)
|
info_handler.setFormatter(formatter)
|
||||||
logger.addHandler(info_handler)
|
logger.addHandler(info_handler)
|
||||||
|
|
||||||
self.logger = logger
|
self.logger = logger
|
||||||
self.printerr = logger.error
|
self.printerr = logger.error
|
||||||
self.printdbg = logger.info
|
self.printdbg = logger.info
|
||||||
|
|
||||||
|
## Global Handler
|
||||||
|
logCur = NewLoggingSystem()
|
||||||
|
Loading…
Reference in New Issue
Block a user