def test_log_config_append_disable_existing_loggers(self): self.config(log_config_append=self.log_config_append) with mock.patch('logging.config.fileConfig') as fileConfig: log.setup('test_log_config_append') fileConfig.assert_called_once_with(self.log_config_append, disable_existing_loggers=False)
def main(): try: CONF = cfg.CONF # Register config options for the logging system log.register_options(CONF) # Init the config object CONF(project='glimpse', version='0.1') # Set some reasonable defaults config.set_defaults(CONF) # Load the logging options from config log.setup(CONF, 'glimpse') # Get our Logging instance LOG = log.getLogger(__name__) LOG.debug("Loading glimpse from %s" % CONF.config_file) # Spit our config out to stderr CONF.log_opt_values(LOG, logging.INFO) # Register eventlet poll, or select wsgi.set_eventlet_hub() # Init and start the WSGI server server = wsgi.Server() server.start(app, default_port=9292) server.wait() except (exception.WorkerCreationFailure, RuntimeError) as e: print("ERROR: %s\n" % exception.exception_to_str(e), file=sys.stderr) sys.exit(1)
def setUp(self): super(LogLevelTestCase, self).setUp() self.CONF = self.useFixture(config.Config()).conf levels = self.CONF.default_log_levels levels.append("nova-test=AUDIT") levels.append("nova-not-debug=WARN") self.config = self.useFixture(config.Config()).config self.config(default_log_levels=levels, verbose=True) log.setup('testing') self.log = log.getLogger('nova-test') self.log_no_debug = log.getLogger('nova-not-debug')
def test_will_not_be_verbose_if_verbose_flag_not_set(self): self.config(verbose=False) log.setup("test_is_not_verbose") logger = logging.getLogger("test_is_not_verbose") self.assertEqual(logging.WARNING, logger.getEffectiveLevel())
def test_will_be_debug_if_debug_flag_set(self): self.config(debug=True) log.setup("test_is_debug") logger = logging.getLogger("test_is_debug") self.assertEqual(logging.DEBUG, logger.getEffectiveLevel())
def test_will_be_verbose_if_verbose_flag_set(self): self.config(verbose=True) log.setup("test_is_verbose") logger = logging.getLogger("test_is_verbose") self.assertEqual(logging.INFO, logger.getEffectiveLevel())
def test_log_config_append_ok(self): self.config(log_config_append=self.log_config_append) log.setup('test_log_config_append')
def test_excepthook_installed(self): log.setup("test_excepthook_installed") self.assertTrue(sys.excepthook != sys.__excepthook__)