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