Ejemplo n.º 1
0
 def test_log_format_overrides_formatter(self):
     self.CONF(['--log-format', '[Any format]'])
     log._setup_logging_from_conf('test', 'test')
     logger = log._loggers[None].logger
     for handler in logger.handlers:
         formatter = handler.formatter
         self.assertTrue(isinstance(formatter, logging.Formatter))
Ejemplo n.º 2
0
 def test_log_format_overrides_formatter(self):
     CONF(['--log-format', '[Any format]'])
     log._setup_logging_from_conf()
     logger = log._loggers[None].logger
     for handler in logger.handlers:
         formatter = handler.formatter
         self.assertTrue(isinstance(formatter, logging.Formatter))
Ejemplo n.º 3
0
 def test_log_dir_handlers(self):
     log_dir = tempfile.mkdtemp()
     self.CONF(["--log-dir", log_dir])
     self.CONF.set_default("use_stderr", False)
     log._setup_logging_from_conf("test", "test")
     logger = log._loggers[None].logger
     self.assertEqual(1, len(logger.handlers))
     self.assertIsInstance(logger.handlers[0], logging.handlers.WatchedFileHandler)
Ejemplo n.º 4
0
    def setUp(self):
        super(CommonLoggerTestsMixIn, self).setUp()
        self.config = self.useFixture(config.Config()).config

        # common context has different fields to the defaults in log.py
        self.config(logging_context_format_string='%(asctime)s %(levelname)s '
                                                  '%(name)s [%(request_id)s '
                                                  '%(user)s %(tenant)s] '
                                                  '%(message)s')
        self.log = None
        log._setup_logging_from_conf('test', 'test')
Ejemplo n.º 5
0
 def test_default_formatter(self):
     log._setup_logging_from_conf('test', 'test')
     logger = log._loggers[None].logger
     for handler in logger.handlers:
         formatter = handler.formatter
         self.assertTrue(isinstance(formatter, log.ContextFormatter))
Ejemplo n.º 6
0
 def test_default_formatter(self):
     log._setup_logging_from_conf()
     logger = log._loggers[None].logger
     for handler in logger.handlers:
         formatter = handler.formatter
         self.assertTrue(isinstance(formatter, log.ContextFormatter))