def test_local_task_logger(self): """ Logging should also work if you run it locally """ setup_event_listening(celery_app) mock_handler = MockLoggingHandler() root_logger = logging.getLogger() root_logger.setLevel(logging.DEBUG) root_logger.addHandler(mock_handler) check = {logging.INFO, logging.WARNING, logging.ERROR, logging.DEBUG} mock_handler.reset() bogus() for record in mock_handler.records: if record.name == 'tkp.distribute.celery.tasks': self.assertTrue(record.levelno in check) check.remove(record.levelno) self.assertFalse(len(check))
def test_remote_task_logger(self): """ make sure the worker log->event->client log mechanism is working. """ setup_event_listening(celery_app) mock_handler = MockLoggingHandler() root_logger = logging.getLogger() root_logger.setLevel(logging.DEBUG) root_logger.addHandler(mock_handler) check = {logging.INFO, logging.WARNING, logging.ERROR} mock_handler.reset() mock_handler.setLevel(logging.INFO) result = bogus() for record in mock_handler.records: if record.name == 'tkp.distribute.celery.tasks': self.assertTrue(record.levelno in check) check.remove(record.levelno) self.assertFalse(len(check))