本文整理汇总了Python中shinken.log.logger.set_level函数的典型用法代码示例。如果您正苦于以下问题:Python set_level函数的具体用法?Python set_level怎么用?Python set_level使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_level函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_basic_logging_error
def test_basic_logging_error(self):
logger.set_level(logger.ERROR)
msgs, lines = self._put_log(logger.error, 'Some log-message')
self.assertEqual(len(msgs), 1)
self.assertEqual(len(lines), 1)
self.assertRegexpMatches(msgs[0], r'^\[\d+\] Error :\s+Some log-message\n$')
self.assertRegexpMatches(lines[0], r'^\[\d+\] Error :\s+Some log-message$')
示例2: test_basic_logging_warning
def test_basic_logging_warning(self):
logger.set_level(logger.WARNING)
msgs, lines = self._put_log(logger.warning, 'Some log-message')
self.assertEqual(len(msgs), 1)
self.assertEqual(len(lines), 1)
self.assertRegexpMatches(msgs[0], r'^\[\d+\] Warning :\s+Some log-message\n$')
self.assertRegexpMatches(lines[0], r'^\[\d+\] Warning :\s+Some log-message$')
示例3: test_basic_logging_info
def test_basic_logging_info(self):
logger.set_level(logger.INFO)
msgs, lines = self._put_log(logger.info, 'Some log-message')
self.assertEqual(len(msgs), 1)
self.assertEqual(len(lines), 1)
self.assertRegexpMatches(msgs[0], r'^\[\d+\] Info :\s+Some log-message\n$')
self.assertRegexpMatches(lines[0], r'^\[\d+\] Info :\s+Some log-message$')
示例4: test_basic_logging_critical
def test_basic_logging_critical(self):
logger.set_level(logger.CRITICAL)
msgs, lines, local_log = self._put_log(logger.critical, 'Some log-message')
self.assertEqual(len(msgs), 1)
self.assertEqual(len(lines), 1)
self.assertEqual(len(local_log), 1)
self.assertRegexpMatches(local_log[0],
r' \[\d+\] Critical :\s+Some log-message\n$')
示例5: test_basic_logging_debug_does_not_send_broks
def test_basic_logging_debug_does_not_send_broks(self):
logger.set_level(logger.DEBUG)
msgs, lines, local_log = self._put_log(logger.debug, 'Some log-message')
self.assertEqual(len(msgs), 0)
self.assertEqual(len(lines), 1)
self.assertEqual(len(local_log), 1)
self.assertRegexpMatches(local_log[0],
r' \[\d+\] Debug :\s+Some log-message$')
示例6: test_register_local_log_keeps_level
def test_register_local_log_keeps_level(self):
logger.set_level(logger.ERROR)
self.assertEqual(logger._level, logger.ERROR)
logfile = NamedTemporaryFile("w")
logfile.close()
logfile_name = logfile.name
logger.register_local_log(logfile_name)
self.assertEqual(logger._level, logger.ERROR)
示例7: test_human_timestamp_format
def test_human_timestamp_format(self):
logger.set_level(logger.INFO)
logger.set_human_format(True)
msgs, lines = self._put_log(logger.info, 'Some ] log-message')
self.assertRegexpMatches(msgs[0],
r'^\[[^\]]+] Info :\s+\[Tiroler Schinken\] Some \] log-message\n$')
time.strptime(msgs[0].split(' Info : ', 1)[0], '[%a %b %d %H:%M:%S %Y]')
self.assertRegexpMatches(lines[0],
r'^\[[^\]]+] Info :\s+\[Tiroler Schinken\] Some \] log-message$')
time.strptime(msgs[0].split(' Info : ', 1)[0], '[%a %b %d %H:%M:%S %Y]')
logger.set_human_format(False)
示例8: test_level_is_higher_then_the_one_set
def test_level_is_higher_then_the_one_set(self):
# just test two samples
logger.set_level(logger.CRITICAL)
msgs, lines = self._put_log(logger.error, 'Some log-message')
self.assertEqual(len(msgs), 0)
self.assertEqual(len(lines), 0)
logger.set_level(logger.INFO)
msgs, lines = self._put_log(logger.debug, 'Some log-message$')
self.assertEqual(len(msgs), 0)
self.assertEqual(len(lines), 0)
示例9: test_load_obj_must_not_change_level
def test_load_obj_must_not_change_level(self):
# argl, load_obj() unsets the level! save and restore it
logger.set_level(logger.CRITICAL)
logger.load_obj(Dummy())
self.assertEqual(logger._level, logger.CRITICAL)
示例10: test_set_level
def test_set_level(self):
logger.set_level(logger.WARNING)
self.assertEqual(logger._level, logger.WARNING)
示例11: Dummy
from shinken.bin import VERSION
except ImportError:
# If importing shinken fails, try to load from current directory
# or parent directory to support running without installation.
# Submodules will then be loaded from there, too.
import imp
imp.load_module('shinken', *imp.find_module('shinken', [os.path.realpath("."), os.path.realpath(".."), os.path.join(os.path.abspath(os.path.dirname(sys.argv[0])), "..")]))
from shinken.bin import VERSION
from shinken.objects.pack import Pack,Packs
from shinken.log import logger
from shinken.objects.config import Config
logger.set_level(10)
class Dummy():
def __init__(self): pass
def add(self, obj) : pass
logger.load_obj(Dummy())
from pymongo.connection import Connection
VERSION = '0.1'
TMP_PATH = '/tmp/pack_analysing'
PACKS_HOME= '/opt/packs'
def do_list(table):
search = table.find()
for s in search: