本文整理汇总了Python中pulp.server.logs.start_logging函数的典型用法代码示例。如果您正苦于以下问题:Python start_logging函数的具体用法?Python start_logging怎么用?Python start_logging使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了start_logging函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_root_logger_configured_console
def test_root_logger_configured_console(self, getLogger, get):
"""
This test ensures that the root logger is configured appropriately when
console logging set.
"""
root_logger = mock.MagicMock(spec=logging.Logger)
root_logger.manager = mock.MagicMock()
root_logger.manager.loggerDict = {}
def fake_getLogger(name=None):
if name is None:
return root_logger
if name not in root_logger.manager.loggerDict:
root_logger.manager.loggerDict[name] = mock.MagicMock()
return root_logger.manager.loggerDict[name]
getLogger.side_effect = fake_getLogger
logs.start_logging()
# Let's make sure the handler is setup right
self.assertEqual(root_logger.addHandler.call_count, 1)
root_handler = root_logger.addHandler.mock_calls[0][1][0]
self.assertTrue(isinstance(root_handler, logging.StreamHandler))
# And the handler should have the formatter with our format string
self.assertTrue(isinstance(root_handler.formatter, logs.TaskLogFormatter))
示例2: test_calls__captureWarnings
def test_calls__captureWarnings(self, _logging):
"""
Ensure that start_logging() calls captureWarnings().
"""
logs.start_logging()
_logging.captureWarnings.assert_called_once_with(True)
示例3: _start_logging
def _start_logging():
"""
Call into Pulp to get the logging started, and set up the logger to be used in this module.
"""
global logger
logs.start_logging()
logger = logging.getLogger(__name__)
示例4: test_calls__blacklist_loggers
def test_calls__blacklist_loggers(self, getLogger, get, _blacklist_loggers):
"""
Ensure that start_logging() calls _blacklist_loggers().
"""
logs.start_logging()
_blacklist_loggers.assert_called_once_with()
示例5: test_root_logger_configured
def test_root_logger_configured(self, getLogger, get):
"""
This test ensures that the root logger is configured appropriately.
"""
root_logger = mock.MagicMock(spec=logging.Logger)
root_logger.manager = mock.MagicMock()
root_logger.manager.loggerDict = {}
def fake_getLogger(name=None):
if name is None:
return root_logger
if name not in root_logger.manager.loggerDict:
root_logger.manager.loggerDict[name] = mock.MagicMock()
return root_logger.manager.loggerDict[name]
getLogger.side_effect = fake_getLogger
logs.start_logging()
# Let's make sure the handler is setup right
self.assertEqual(root_logger.addHandler.call_count, 1)
root_handler = root_logger.addHandler.mock_calls[0][1][0]
self.assertTrue(isinstance(root_handler, logs.CompliantSysLogHandler))
self.assertEqual(root_handler.address, os.path.join("/", "dev", "log"))
self.assertEqual(root_handler.facility, logs.CompliantSysLogHandler.LOG_DAEMON)
# And the handler should have the formatter with our format string
self.assertEqual(root_handler.formatter._fmt, logs.LOG_FORMAT_STRING)
示例6: setUpClass
def setUpClass(cls):
if not os.path.exists('/tmp/pulp'):
os.makedirs('/tmp/pulp')
stop_logging()
config_filename = os.path.join(TEST_DATA_DIR, 'test-override-pulp.conf')
config.config.read(config_filename)
start_logging()
manager_factory.initialize()
constants.DISTRIBUTION_STORAGE_PATH = TEMP_DISTRO_STORAGE_DIR
示例7: test_calls__captureWarnings_with_attribute_error
def test_calls__captureWarnings_with_attribute_error(self, _logging):
"""
Ensure that start_logging() calls captureWarnings() and handles AttributeError
The validation for this is that the AttributeError is swallowed.
"""
_logging.captureWarnings.side_effect = AttributeError
logs.start_logging()
_logging.captureWarnings.assert_called_once_with(True)
示例8: setUpClass
def setUpClass(cls):
if not os.path.exists('/tmp/pulp'):
os.makedirs('/tmp/pulp')
stop_logging()
config_filename = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'data', 'test-override-pulp.conf')
config.config.read(config_filename)
start_logging()
name = config.config.get('database', 'name')
connection.initialize(name)
manager_factory.initialize()
示例9: _start_logging
def _start_logging():
"""
Call into Pulp to get the logging started, and set up the logger to be used in this module.
"""
global logger
logs.start_logging()
logger = logging.getLogger(__name__)
console_handler = logging.StreamHandler()
console_handler.setLevel(logging.INFO)
logger.root.addHandler(console_handler)
示例10: setUpClass
def setUpClass(cls):
if not os.path.exists('/tmp/pulp'):
os.makedirs('/tmp/pulp')
stop_logging()
config_filename = os.path.join(os.path.abspath(os.path.dirname(__file__)),
'../../../pulp_rpm/test/unit/data', 'test-override-pulp.conf')
config.config.read(config_filename)
start_logging()
name = config.config.get('database', 'name')
connection.initialize(name)
manager_factory.initialize()
constants.DISTRIBUTION_STORAGE_PATH = TEMP_DISTRO_STORAGE_DIR
示例11: load_test_config
def load_test_config():
if not os.path.exists('/tmp/pulp'):
os.makedirs('/tmp/pulp')
override_file = os.path.join(DATA_DIR, 'test-override-pulp.conf')
stop_logging()
try:
config.add_config_file(override_file)
except RuntimeError:
pass
start_logging()
return config.config
示例12: load_test_config
def load_test_config():
if not os.path.exists('/tmp/pulp'):
os.makedirs('/tmp/pulp')
override_file = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'data', 'test-override-pulp.conf')
override_repo_file = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'data', 'test-override-repoauth.conf')
stop_logging()
try:
config.add_config_file(override_file)
config.add_config_file(override_repo_file)
except RuntimeError:
pass
start_logging()
return config.config
示例13: _start_logging
def _start_logging():
"""
Call into Pulp to get the logging started, and set up the _logger to be used in this module.
"""
global _logger
logs.start_logging()
_logger = logging.getLogger(__name__)
console_handler = logging.StreamHandler()
console_handler.setLevel(logging.INFO)
_logger.root.addHandler(console_handler)
# Django will un-set our default ignoring DeprecationWarning *unless* sys.warnoptions is set.
# So, set it as though '-W ignore::DeprecationWarning' was passed on the commandline. Our code
# that sets DeprecationWarnings as ignored also checks warnoptions, so this must be added after
# pulp.server.logs.start_logging is called but before Django is initialized.
sys.warnoptions.append('ignore::DeprecationWarning')
示例14: _load_test_config
def _load_test_config():
"""
Load the test database configuration information.
"""
stop_logging()
config.config.set('database', 'name', 'pulp_unittest')
config.config.set('server', 'storage_dir', '/tmp/pulp')
# Prevent the tests from altering the config so that nobody accidentally makes global changes
config.config.set = _enforce_config
config.load_configuration = _enforce_config
config.__setattr__ = _enforce_config
config.config.__setattr__ = _enforce_config
start_logging()
示例15: setUpClass
def setUpClass(cls):
if not os.path.exists(cls.TMP_ROOT):
os.makedirs(cls.TMP_ROOT)
stop_logging()
path = os.path.join(
os.path.abspath(os.path.dirname(__file__)),
'data',
'pulp.conf')
pulp_conf.read(path)
start_logging()
storage_dir = pulp_conf.get('server', 'storage_dir')
if not os.path.exists(storage_dir):
os.makedirs(storage_dir)
shutil.rmtree(storage_dir+'/*', ignore_errors=True)
name = pulp_conf.get('database', 'name')
connection.initialize(name)
managers.initialize()