def test_setup_logging_via_file(self): logfile = self.create_tempfiles([('seedbox', ''.join(self.log_cfg_data))], '.log')[0] self.CONF.set_override('logconfig', logfile) service._setup_logging() root = logging.getLogger() self.assertEqual(logging.DEBUG, root.getEffectiveLevel())
def test_setup_logging_no_logfile(self): self.CONF.set_override('logfile', None) del logging.getLogger().handlers[:] service._setup_logging() for hndler in logging.getLogger().handlers: self.assertThat( hndler, matchers.MatchesAny( matchers.IsInstance(logging.StreamHandler), matchers.IsInstance(logging.NullHandler)))
def test_setup_logging_cron(self): self.CONF.set_override('cron', True) del logging.getLogger().handlers[:] service._setup_logging() for hndler in logging.getLogger().handlers: self.assertThat( hndler, matchers.MatchesAny( matchers.IsInstance(logging.handlers.RotatingFileHandler), matchers.IsInstance(logging.NullHandler)))
def test_setup_logging(self): del logging.getLogger().handlers[:] service._setup_logging() self.assertEqual(logging.getLogger().getEffectiveLevel(), logging.INFO) self.assertEqual(logging.getLogger('sqlalchemy').getEffectiveLevel(), logging.ERROR) for hndler in logging.getLogger().handlers: self.assertThat( hndler, matchers.MatchesAny( matchers.IsInstance(logging.handlers.RotatingFileHandler), matchers.IsInstance(logging.StreamHandler), matchers.IsInstance(logging.NullHandler)))