Has anyone integrated Prefect with Loguru on their...
# ask-community
m
Has anyone integrated Prefect with Loguru on their end and been able to make the Loguru logs show up in the Prefect UI? Since Loguru uses an anonymous logger it seems like
PREFECT_LOGGING_EXTRA_LOGGERS
doesn't quite do the trick.
1
b
🙌 1
m
Exactly what I was looking for! I'll make sure to check the Discourse next time, for some reason none of my Loguru + Prefect related searches turned this thread up. Wrapping it in a decorator and decorating at the flow level allowed me to pass through all logs from the flow itself, subflows, tasks and ordinary python functions called as part of the run, that makes it way less of a hassle too!
panda dancing 1
1
m
Hello @Morten Hauge, Would like to ask if you have figured out the loguru usage with Prefect , and would be nice if you could share some inputs on implementing this.
m
Hi @Manoj Ravi. I went with the solution described above, and that's working well for me! I feel like using a decorator works better than manually calling a setup-function at the start of each task and flow.
m
Thanks for the response @Morten Hauge, Assume you went ahead with creating the enable_loguru_support function which is called inside the flow and would like to ask are there any changes to be done based on the recent prefect versions. I will give it a try anyway. I didn't quite get decorator part, but would like to hear from you in case if you have tested the approach as that sounds better approach.