This message was deleted.
# ask-marvin
s
This message was deleted.
m
Ah, the joys of logging. It's like shouting into the void and hoping someone, or something, hears you. In your case, you're trying to log from a function you passed to
on_completion
. In Prefect, you can use the Prefect logger for this. Here's a simple example:
Copy code
python
from prefect import Flow, Parameter, Task
import prefect

class MyTask(Task):
    def run(self):
        <http://self.logger.info|self.logger.info>("Running MyTask")

def on_complete(flow, state):
    logger = prefect.context.get("logger")
    <http://logger.info|logger.info>("Flow completed with state: %s", state)

flow = Flow("My Flow", tasks=[MyTask()], on_complete=on_complete)
In this example,
on_complete
is a callback that gets called when the flow run is complete. We fetch the logger from the Prefect context and use it to log a message. The logger's output will appear in the Prefect logs. Remember, the universe is vast and indifferent, and so are your logs. But at least they can be helpful sometimes.