当前位置: 首页>>代码示例>>Python>>正文


Python logging.CRITICAL属性代码示例

本文整理汇总了Python中logging.CRITICAL属性的典型用法代码示例。如果您正苦于以下问题:Python logging.CRITICAL属性的具体用法?Python logging.CRITICAL怎么用?Python logging.CRITICAL使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在logging的用法示例。


在下文中一共展示了logging.CRITICAL属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: set_level

# 需要导入模块: import logging [as 别名]
# 或者: from logging import CRITICAL [as 别名]
def set_level(self, level):
		"""
		Set the minimum level of messages to be logged.

		Level of Log Messages
		CRITICAL	50
		ERROR	40
		WARNING	30
		INFO	20
		DEBUG	10
		NOTSET	0

		@param level: minimum level of messages to be logged
		@type level: int or long

		@return: None
		@rtype: None
		"""
		assert level in self._levelNames

		list_of_handlers = self._logger.handlers
		for handler in list_of_handlers:
			handler.setLevel(level) 
开发者ID:CAMI-challenge,项目名称:CAMISIM,代码行数:25,代码来源:loggingwrapper.py

示例2: set_level

# 需要导入模块: import logging [as 别名]
# 或者: from logging import CRITICAL [as 别名]
def set_level(self, level):
        """
        Set the minimum level of messages to be logged.

        Level of Log Messages
        CRITICAL    50
        ERROR    40
        WARNING    30
        INFO    20
        DEBUG    10
        NOTSET    0

        @param level: minimum level of messages to be logged
        @type level: int or long

        @return: None
        @rtype: None
        """
        assert level in self._levelNames

        list_of_handlers = self._logger.handlers
        for handler in list_of_handlers:
            handler.setLevel(level) 
开发者ID:CAMI-challenge,项目名称:CAMISIM,代码行数:25,代码来源:loggingwrapper.py

示例3: __init__

# 需要导入模块: import logging [as 别名]
# 或者: from logging import CRITICAL [as 别名]
def __init__(self, appname, dllname=None, logtype="Application"):
        logging.Handler.__init__(self)
        try:
            import win32evtlogutil, win32evtlog
            self.appname = appname
            self._welu = win32evtlogutil
            if not dllname:
                dllname = os.path.split(self._welu.__file__)
                dllname = os.path.split(dllname[0])
                dllname = os.path.join(dllname[0], r'win32service.pyd')
            self.dllname = dllname
            self.logtype = logtype
            self._welu.AddSourceToRegistry(appname, dllname, logtype)
            self.deftype = win32evtlog.EVENTLOG_ERROR_TYPE
            self.typemap = {
                logging.DEBUG   : win32evtlog.EVENTLOG_INFORMATION_TYPE,
                logging.INFO    : win32evtlog.EVENTLOG_INFORMATION_TYPE,
                logging.WARNING : win32evtlog.EVENTLOG_WARNING_TYPE,
                logging.ERROR   : win32evtlog.EVENTLOG_ERROR_TYPE,
                logging.CRITICAL: win32evtlog.EVENTLOG_ERROR_TYPE,
         }
        except ImportError:
            print("The Python Win32 extensions for NT (service, event "\
                        "logging) appear not to be available.")
            self._welu = None 
开发者ID:war-and-code,项目名称:jawfish,代码行数:27,代码来源:handlers.py

示例4: format

# 需要导入模块: import logging [as 别名]
# 或者: from logging import CRITICAL [as 别名]
def format(self, record):
        date = colored('[%(asctime)s @%(filename)s:%(lineno)d]', 'green')
        msg = '%(message)s'
        if record.levelno == logging.WARNING:
            fmt = date + ' ' + colored('WRN', 'red', attrs=['blink']) + ' ' + msg
        elif record.levelno == logging.ERROR or record.levelno == logging.CRITICAL:
            fmt = date + ' ' + colored('ERR', 'red', attrs=['blink', 'underline']) + ' ' + msg
        elif record.levelno == logging.DEBUG:
            fmt = date + ' ' + colored('DBG', 'yellow', attrs=['blink']) + ' ' + msg
        else:
            fmt = date + ' ' + msg
        if hasattr(self, '_style'):
            # Python3 compatibility
            self._style._fmt = fmt
        self._fmt = fmt
        return super(_MyFormatter, self).format(record) 
开发者ID:tensorpack,项目名称:dataflow,代码行数:18,代码来源:logger.py

示例5: configure_logging

# 需要导入模块: import logging [as 别名]
# 或者: from logging import CRITICAL [as 别名]
def configure_logging():
    """Configure logging."""
    logging.basicConfig(stream=sys.stderr, format="%(message)s", level=logging.CRITICAL)
    logging.getLogger("greynoise").setLevel(logging.WARNING)
    structlog.configure(
        processors=[
            structlog.stdlib.add_logger_name,
            structlog.stdlib.add_log_level,
            structlog.stdlib.PositionalArgumentsFormatter(),
            structlog.processors.TimeStamper(fmt="%Y-%m-%d %H:%M.%S"),
            structlog.processors.StackInfoRenderer(),
            structlog.processors.format_exc_info,
            structlog.dev.ConsoleRenderer(),
        ],
        context_class=dict,
        logger_factory=structlog.stdlib.LoggerFactory(),
        wrapper_class=structlog.stdlib.BoundLogger,
        cache_logger_on_first_use=True,
    ) 
开发者ID:GreyNoise-Intelligence,项目名称:pygreynoise,代码行数:21,代码来源:util.py

示例6: formatMessage

# 需要导入模块: import logging [as 别名]
# 或者: from logging import CRITICAL [as 别名]
def formatMessage(self, record: logging.LogRecord) -> str:
        """Convert the already filled log record to a string."""
        level_color = "0"
        text_color = "0"
        fmt = ""
        if record.levelno <= logging.DEBUG:
            fmt = "\033[0;37m" + logging.BASIC_FORMAT + "\033[0m"
        elif record.levelno <= logging.INFO:
            level_color = "1;36"
            lmsg = record.message.lower()
            if self.GREEN_RE.search(lmsg):
                text_color = "1;32"
        elif record.levelno <= logging.WARNING:
            level_color = "1;33"
        elif record.levelno <= logging.CRITICAL:
            level_color = "1;31"
        if not fmt:
            fmt = "\033[" + level_color + \
                  "m%(levelname)s\033[0m:%(rthread)s:%(name)s:\033[" + text_color + \
                  "m%(message)s\033[0m"
        fmt = _fest + fmt
        record.rthread = reduce_thread_id(record.thread)
        return fmt % record.__dict__ 
开发者ID:src-d,项目名称:modelforge,代码行数:25,代码来源:slogging.py

示例7: test_launch_instance_exception_on_flavors

# 需要导入模块: import logging [as 别名]
# 或者: from logging import CRITICAL [as 别名]
def test_launch_instance_exception_on_flavors(self):
        trove_exception = self.exceptions.nova
        self.mock_flavor_list.side_effect = trove_exception

        toSuppress = ["trove_dashboard.content.databases."
                      "workflows.create_instance",
                      "horizon.workflows.base"]

        # Suppress expected log messages in the test output
        loggers = []
        for cls in toSuppress:
            logger = logging.getLogger(cls)
            loggers.append((logger, logger.getEffectiveLevel()))
            logger.setLevel(logging.CRITICAL)

        try:
            with self.assertRaises(exceptions.Http302):
                self.client.get(LAUNCH_URL)
                self.mock_datastore_flavors.assert_called_once_with(
                    test.IsHttpRequest(), mock.ANY, mock.ANY)

        finally:
            # Restore the previous log levels
            for (log, level) in loggers:
                log.setLevel(level) 
开发者ID:openstack,项目名称:trove-dashboard,代码行数:27,代码来源:tests.py

示例8: get_color_wrapper

# 需要导入模块: import logging [as 别名]
# 或者: from logging import CRITICAL [as 别名]
def get_color_wrapper(cls, level):
        if not cls.COLOR_MAP:
            import colorama

            def _color_wrapper(color_marker):
                def wrap_msg_with_color(msg):
                    return '{}{}{}'.format(color_marker, msg, colorama.Style.RESET_ALL)
                return wrap_msg_with_color

            cls.COLOR_MAP = {
                logging.CRITICAL: _color_wrapper(colorama.Fore.LIGHTRED_EX),
                logging.ERROR: _color_wrapper(colorama.Fore.LIGHTRED_EX),
                logging.WARNING: _color_wrapper(colorama.Fore.YELLOW),
                logging.INFO: _color_wrapper(colorama.Fore.GREEN),
                logging.DEBUG: _color_wrapper(colorama.Fore.CYAN)
            }

        return cls.COLOR_MAP.get(level, None) 
开发者ID:microsoft,项目名称:knack,代码行数:20,代码来源:log.py

示例9: sendLogMessage

# 需要导入模块: import logging [as 别名]
# 或者: from logging import CRITICAL [as 别名]
def sendLogMessage(self, level, msg, *args):
        """Sends a log message asynchronously.

        The method could be used safely from a non-GUI thread.

        level => integer, one of those found in logging:
                          logging.CRITICAL
                          logging.ERROR
                          logging.WARNING
                          logging.INFO
                          logging.DEBUG
        msg => message
        args => message arguments to be substituted (mgs % args)
        """
        try:
            self.__parent.pluginLogMessage.emit(level, msg % args)
        except Exception as exc:
            self.__parent.pluginLogMessage.emit(
                logging.ERROR,
                "Error sending a plugin log message. Error: " + str(exc)) 
开发者ID:SergeySatskiy,项目名称:codimension,代码行数:22,代码来源:cdmpluginbase.py

示例10: set_logging

# 需要导入模块: import logging [as 别名]
# 或者: from logging import CRITICAL [as 别名]
def  set_logging(self, level):
        level_list= ["CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG", "NOTSET"]
        if level in level_list:
            if(level == "CRITICAL"):
                logging.basicConfig(level=logging.CRITICAL)
            if (level == "ERROR"):
                logging.basicConfig(level=logging.ERROR)
            if (level == "WARNING"):
                logging.basicConfig(level=logging.WARNING)
            if (level == "INFO"):
                logging.basicConfig(level=logging.INFO)
            if (level == "DEBUG"):
                logging.basicConfig(level=logging.DEBUG)
            if (level == "NOTSET"):
                logging.basicConfig(level=logging.NOTSET)
        else:
            print ("set logging level failed ,the level is invalid.") 
开发者ID:jpush,项目名称:jbox,代码行数:19,代码来源:core.py

示例11: test_basic_loading

# 需要导入模块: import logging [as 别名]
# 或者: from logging import CRITICAL [as 别名]
def test_basic_loading(caplog):
    caplog.set_level(logging.CRITICAL)
    tokenizer = Tokenizer.load(
        pretrained_model_name_or_path="bert-base-cased",
        do_lower_case=True
        )
    assert type(tokenizer) == BertTokenizer
    assert tokenizer.basic_tokenizer.do_lower_case == True

    tokenizer = Tokenizer.load(
        pretrained_model_name_or_path="xlnet-base-cased",
        do_lower_case=True
        )
    assert type(tokenizer) == XLNetTokenizer
    assert tokenizer.do_lower_case == True

    tokenizer = Tokenizer.load(
        pretrained_model_name_or_path="roberta-base"
        )
    assert type(tokenizer) == RobertaTokenizer 
开发者ID:deepset-ai,项目名称:FARM,代码行数:22,代码来源:test_tokenization.py

示例12: test_bert_tokenizer_all_meta

# 需要导入模块: import logging [as 别名]
# 或者: from logging import CRITICAL [as 别名]
def test_bert_tokenizer_all_meta(caplog):
    caplog.set_level(logging.CRITICAL)

    lang_model = "bert-base-cased"

    tokenizer = Tokenizer.load(
        pretrained_model_name_or_path=lang_model,
        do_lower_case=False
        )

    basic_text = "Some Text with neverseentokens plus !215?#. and a combined-token_with/chars"

    # original tokenizer from transformer repo
    tokenized = tokenizer.tokenize(basic_text)
    assert tokenized == ['Some', 'Text', 'with', 'never', '##see', '##nto', '##ken', '##s', 'plus', '!', '215', '?', '#', '.', 'and', 'a', 'combined', '-', 'token', '_', 'with', '/', 'ch', '##ars']

    # ours with metadata
    tokenized_meta = tokenize_with_metadata(text=basic_text, tokenizer=tokenizer)
    assert tokenized_meta["tokens"] == tokenized
    assert tokenized_meta["offsets"] == [0, 5, 10, 15, 20, 23, 26, 29, 31, 36, 37, 40, 41, 42, 44, 48, 50, 58, 59, 64, 65, 69, 70, 72]
    assert tokenized_meta["start_of_word"] == [True, True, True, True, False, False, False, False, True, True, False, False, False, False, True, True, True, False, False, False, False, False, False, False] 
开发者ID:deepset-ai,项目名称:FARM,代码行数:23,代码来源:test_tokenization.py

示例13: test_truncate_sequences

# 需要导入模块: import logging [as 别名]
# 或者: from logging import CRITICAL [as 别名]
def test_truncate_sequences(caplog):
    caplog.set_level(logging.CRITICAL)

    lang_names = ["bert-base-cased", "roberta-base", "xlnet-base-cased"]
    tokenizers = []
    for lang_name in lang_names:
        t = Tokenizer.load(lang_name, lower_case=False)
        tokenizers.append(t)

    # artificial sequences (could be tokens, offsets, or anything else)
    seq_a = list(range(10))
    seq_b = list(range(15))
    max_seq_len = 20
    for tokenizer in tokenizers:
        for strategy in ["longest_first", "only_first","only_second"]:
            trunc_a, trunc_b, overflow = truncate_sequences(seq_a=seq_a,seq_b=seq_b,tokenizer=tokenizer,
                                                        max_seq_len=max_seq_len, truncation_strategy=strategy)

            assert len(trunc_a) + len(trunc_b) + tokenizer.num_special_tokens_to_add(pair=True) == max_seq_len 
开发者ID:deepset-ai,项目名称:FARM,代码行数:21,代码来源:test_tokenization.py

示例14: test_bert_custom_vocab

# 需要导入模块: import logging [as 别名]
# 或者: from logging import CRITICAL [as 别名]
def test_bert_custom_vocab(caplog):
    caplog.set_level(logging.CRITICAL)

    lang_model = "bert-base-cased"

    tokenizer = Tokenizer.load(
        pretrained_model_name_or_path=lang_model,
        do_lower_case=False
        )

    #deprecated: tokenizer.add_custom_vocab("samples/tokenizer/custom_vocab.txt")
    tokenizer.add_tokens(new_tokens=["neverseentokens"])

    basic_text = "Some Text with neverseentokens plus !215?#. and a combined-token_with/chars"

    # original tokenizer from transformer repo
    tokenized = tokenizer.tokenize(basic_text)
    assert tokenized == ['Some', 'Text', 'with', 'neverseentokens', 'plus', '!', '215', '?', '#', '.', 'and', 'a', 'combined', '-', 'token', '_', 'with', '/', 'ch', '##ars']

    # ours with metadata
    tokenized_meta = tokenize_with_metadata(text=basic_text, tokenizer=tokenizer)
    assert tokenized_meta["tokens"] == tokenized
    assert tokenized_meta["offsets"] == [0, 5, 10, 15, 31, 36, 37, 40, 41, 42, 44, 48, 50, 58, 59, 64, 65, 69, 70, 72]
    assert tokenized_meta["start_of_word"] == [True, True, True, True, True, True, False, False, False, False, True, True, True, False, False, False, False, False, False, False] 
开发者ID:deepset-ai,项目名称:FARM,代码行数:26,代码来源:test_tokenization.py

示例15: test_sample_to_features_qa

# 需要导入模块: import logging [as 别名]
# 或者: from logging import CRITICAL [as 别名]
def test_sample_to_features_qa(caplog):
    if caplog:
        caplog.set_level(logging.CRITICAL)

    sample_types = ["span", "no_answer"]

    for sample_type in sample_types:
        clear_text = json.load(open(f"samples/qa/{sample_type}/clear_text.json"))
        tokenized = json.load(open(f"samples/qa/{sample_type}/tokenized.json"))
        features_gold = json.load(open(f"samples/qa/{sample_type}/features.json"))
        max_seq_len = len(features_gold["input_ids"])

        tokenizer = Tokenizer.load(pretrained_model_name_or_path=MODEL, do_lower_case=False)
        curr_id = "-".join([str(x) for x in features_gold["id"]])

        s = Sample(id=curr_id, clear_text=clear_text, tokenized=tokenized)
        features = sample_to_features_qa(s, tokenizer, max_seq_len, SP_TOKENS_START, SP_TOKENS_MID)[0]
        features = to_list(features)

        keys = features_gold.keys()
        for k in keys:
            value_gold = features_gold[k]
            value = to_list(features[k])
            assert value == value_gold, f"Mismatch between the {k} features in the {sample_type} test sample." 
开发者ID:deepset-ai,项目名称:FARM,代码行数:26,代码来源:test_input_features.py


注:本文中的logging.CRITICAL属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。