So I’m quite new with Prefect. I’m getting to know 2.0 and and I have some flows that I’m working on. I have quite a lot of code in functions or classes that I would want to import from external files and use withing flows and tasks. Most of that code is used for data manipulation and occasionally I need to print out certain things. I just cannot seem to be able to figure out how to get that to show in the logs.
As an example I might have a file called helpers.py:
from prefect import flow, get_run_logger
from helpers import say_hi
logger = get_run_logger()
logger.info("Flow level message. Works fine")
How to get that “Hi!” shown? I would be happy to just replace the standard logger with prefect logger but that doesn’t seem to be possible outside of a flow or task context.
I tried to look into adding extra loggers but didn’t exactly understand if and how it would work in this case.
I noticed that in Prefect 1.0 it seems to be possible to forward the output of stdout to a logger by setting log_stdout=True on the task. Something like that would be totally fine for me if I could just print instead of using the logger but apparently that is not possible in 2.0.
Any guidance on how to achieve this? I hope the explanation was clear enough.