If I wanted to log flow run information in a custo...
# ask-community
b
If I wanted to log flow run information in a custom way, is there a built-in or supported way to do this?
I am migrating a new flow to prefect and my legacy code has a little decorator that logs "flow runs" (start, stop, final state) to a database. I probably don't want or need to port this functionality into my prefect code (bc Cloud handles it for me), but I'm curious if I could.
k
What are you thinking? Like attaching a file handler or sending it somewhere? Do you mean logging more stuff, changing the content of the logs, or outputting it somewhere?
b
More like a database entry (say my own postgres db)... flow name (or id), flow run id, and start time, etc
Not "logs" per se
k
Ohh you can just log it by logging it from the context. Or am I missing something?
b
I might be describing it poorly. I guess I'm really asking is there a way for me to backup my flow run history somewhere other than wherever prefect cloud is storing it?
Obviously I could write some job to query the prefect api and then write to whatever database I wished, which seems more trouble than it's worth so I don't plan to do that.
k
Ah ok. The quick answer then is not immediately. You’d need a job of sorts for sure. Unless you use the Flow state handler and context to write them out somewhere
b
Yea flow state handler makes sense. That would actually work well. Probably not worth the trouble though. Thanks!!