Gencaster / gencaster

A non-linear audio streaming framework for real-time radiophonic experiences and live music.
https://gencaster.org
GNU Affero General Public License v3.0
20 stars 0 forks source link

Add logging of stream variables #468

Open capital-G opened 1 year ago

capital-G commented 1 year ago

Maybe createa flag for a Graph. This does not need to be stored in the database but maybe in a file?

          Lets create a script which logs all GPS variables

Originally posted by @capital-G in https://github.com/Gencaster/gencaster/issues/6#issuecomment-1600551546

capital-G commented 1 year ago

If the variable is forwarded to SC it is possible to log them like this :)

docker compose logs -f -t -n 10 sound > gps.log
capital-G commented 1 year ago

It would be cool to show the logs in general in some kind within the editor. Maybe it is possible to store all logs and past-variables in redis? :o

capital-G commented 1 year ago

Maybe it is possible to add a watcher to our sclogs which pumps them into our database. If we add a Stream enter- and exit datetime it is possible to filter the logs. Via a subscription / redis push it would be possible to update also the logs while they are happening.

capital-G commented 1 year ago

This is way harder than I thought it would be. Currently there are two problems

a) If the log is yield in an async context it is not possible to push it into the database as the db connection requires a sync environment. Wrapping this requires a yield which is only available in an async function, but the default handler only has a sync interface b) Currently I use logging.Filter to add a state to a logger - but this logger is not shared with other loggers, but this is mandatory as we want to set the state for a given context. (although I thought using the root logger would solve this?)

There is a blog entry https://rob-blackbourn.medium.com/how-to-use-python-logging-queuehandler-with-dictconfig-1e8b1284e27a which describes how to setup django using a Queue Handler

Also taking a look at the sentry sdk could be interesting as they sufffer from the same problem? I found https://github.com/getsentry/sentry-python/blob/026d6090247547637d4c607b95308b6271ab9dfc/sentry_sdk/integrations/django/asgi.py#L25-L42 but I still don't understand it fully.

I think the best would be to setup a small test project to figure this out in an easy way.