diff --git a/src/xfel_calibrate/setup_logging.py b/src/xfel_calibrate/setup_logging.py index ae8cbda320238baf334596650bc455e622cad1d4..b9237517c50870e9d492672939d1799611004256 100644 --- a/src/xfel_calibrate/setup_logging.py +++ b/src/xfel_calibrate/setup_logging.py @@ -1,13 +1,13 @@ +import json import os import sys -import json import warnings -import IPython from datetime import datetime -from typing import Type, Any +from typing import Any, Type -from cal_tools.warnings import CalibrationWarning +import IPython +from cal_tools.warnings import CalibrationWarning JOB_ID = os.getenv('SLURM_JOB_ID', 'local') @@ -44,8 +44,10 @@ def log_error( except Exception as e: sys.stdout.write(f"Logging failed: {e}\n") + original_showwarning = warnings.showwarning + def handle_warning( message: Warning, category: Type[Warning], # these are needed for `warnings.showwarning`