Dev Dabke
11/16/2022, 4:28 PMlogger
created as a singleton in a python module. However, sometimes, this module is invoked in a prefect flow. The logs from this logger are not displaying during the flow run, nor or they logging to orion. I am not invoking get_run_logger
anywhere. The issue is that the module is only sometimes invoked in the context of a flow; it’s a shared library. Can I register prefect as a handle to this logger that will only log when in a prefect context?Mason Menges
11/16/2022, 10:09 PMDev Dabke
11/17/2022, 3:00 PM# HACK: a disgusting hack to get logs to prefect.
if importlib.util.find_spec("prefect"):
try:
from prefect import ( # pylint: disable=import-outside-toplevel
get_run_logger,
)
global logger
logger = get_run_logger() # pylint: disable=redefined-outer-name
except: # pylint: disable=bare-except
pass