Coverage for gwcelery/voevent/logging.py: 100%

10 statements  

« prev     ^ index     » next       coverage.py v7.4.4, created at 2024-11-14 05:52 +0000

1"""Integration between the Celery, Twisted, and Comet logging systems.""" 

2 

3import comet.log 

4from celery.signals import after_setup_logger 

5from celery.utils.log import get_logger 

6from twisted.python.log import PythonLoggingObserver 

7 

8log = get_logger(__name__) 

9 

10__all__ = ('after_setup_logger', 'log') 

11 

12 

13@after_setup_logger.connect 

14def after_setup_logger(logger, loglevel, **kwargs): 

15 """Celery :doc:`signal handler <celery:userguide/signals>` to set up 

16 capturing of all log messages from Comet and Twisted. 

17 

18 * Celery uses the Python standard library's :mod:`logging` module. Twisted 

19 has its own separate logging facility. Use Twisted's 

20 :class:`~twisted.python.log.PythonLoggingObserver` to forward all Twisted 

21 log messages to the Python :mod:`logging` module. 

22 

23 * Comet uses the Twisted logging facility, but has its own separate 

24 management of log severity level (e.g., *info*, *debug*). Set Comet's log 

25 level to match Celery's. 

26 """ 

27 comet.log.LEVEL = 10 * loglevel 

28 PythonLoggingObserver(logger.name).start()