getlogbook / logbook

A cool logging replacement for Python.
http://logbook.readthedocs.org
Other
1.48k stars 165 forks source link

Simplify context #370

Open RazerM opened 10 months ago

RazerM commented 10 months ago

Logbook has a ContextObject which is used by various objects, most notably the Handler class. As a context manager, these objects will push either greenlet or thread context depending on whether "gevent" support is enabled. There are explicit contextmanagers, push, and pop methods for each variant:

application context is global and so still has a purpose.

contextvars is available in all the Python versions we support, and greenlet 1.0+ supports it natively, so we can get rid of the thread/greenlet variants.

I wonder if we can already deprecate them and make them use context underneath.