logger updated
This commit is contained in:
parent
adb41ffb35
commit
29c871367e
|
@ -2,6 +2,7 @@ import logging
|
||||||
import logging.handlers
|
import logging.handlers
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
import threading
|
import threading
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
class Logger:
|
class Logger:
|
||||||
|
@ -11,6 +12,7 @@ class Logger:
|
||||||
__queue = None
|
__queue = None
|
||||||
__thread = None
|
__thread = None
|
||||||
__setup = False
|
__setup = False
|
||||||
|
__handlers = []
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def __logger_listener(cls, q):
|
def __logger_listener(cls, q):
|
||||||
|
@ -62,6 +64,21 @@ class Logger:
|
||||||
|
|
||||||
cls.__setup = True
|
cls.__setup = True
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def add_handler(cls, path: Path):
|
||||||
|
root = logging.getLogger("listener")
|
||||||
|
rh = logging.FileHandler(path, mode="a")
|
||||||
|
rh.setLevel(logging.DEBUG)
|
||||||
|
cls.__handlers.append(rh)
|
||||||
|
root.addHandler(rh)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def clear_handlers(cls):
|
||||||
|
root = logging.getLogger("listener")
|
||||||
|
for h in cls.__handlers:
|
||||||
|
root.removeHandler(h)
|
||||||
|
cls.__handlers.clear()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def queue(cls):
|
def queue(cls):
|
||||||
if not cls.__setup:
|
if not cls.__setup:
|
||||||
|
|
|
@ -27,6 +27,7 @@ def estimate_comparison():
|
||||||
prevs=env.DATASET_PREVS,
|
prevs=env.DATASET_PREVS,
|
||||||
)
|
)
|
||||||
create_dataser_dir(dataset.name, update=env.DATASET_DIR_UPDATE)
|
create_dataser_dir(dataset.name, update=env.DATASET_DIR_UPDATE)
|
||||||
|
Logger.add_handler(env.OUT_DIR / f"{dataset.name}.log")
|
||||||
try:
|
try:
|
||||||
dr = comp.evaluate_comparison(
|
dr = comp.evaluate_comparison(
|
||||||
dataset,
|
dataset,
|
||||||
|
@ -52,6 +53,7 @@ def estimate_comparison():
|
||||||
f"Failed while saving configuration {plot_conf} of {dataset.name}. Exception: {e}"
|
f"Failed while saving configuration {plot_conf} of {dataset.name}. Exception: {e}"
|
||||||
)
|
)
|
||||||
traceback(e)
|
traceback(e)
|
||||||
|
Logger.clear_handlers()
|
||||||
|
|
||||||
# print(df.to_latex(float_format="{:.4f}".format))
|
# print(df.to_latex(float_format="{:.4f}".format))
|
||||||
# print(utils.avg_group_report(df).to_latex(float_format="{:.4f}".format))
|
# print(utils.avg_group_report(df).to_latex(float_format="{:.4f}".format))
|
||||||
|
|
Loading…
Reference in New Issue