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


Python logger.critical方法代码示例

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


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

示例1: write

# 需要导入模块: from loguru import logger [as 别名]
# 或者: from loguru.logger import critical [as 别名]
def write(self,msg,level='info'):
        "Write out a message"
        fname = inspect.stack()[2][3] #May be use a entry-exit decorator instead        
        d = {'caller_func': fname}                    
        if level.lower()== 'debug': 
            logger.debug("{module} | {msg}",module=d['caller_func'],msg=msg)                      
        elif level.lower()== 'info':
            logger.info("{module} | {msg}",module=d['caller_func'],msg=msg)           
        elif level.lower()== 'warn' or level.lower()=='warning':           
            logger.warning("{module} | {msg}",module=d['caller_func'],msg=msg)
        elif level.lower()== 'error':
            logger.error("{module} | {msg}",module=d['caller_func'],msg=msg)            
        elif level.lower()== 'critical':   
            logger.critical("{module} | {msg}",module=d['caller_func'],msg=msg)            
        else:
            logger.critical("Unknown level passed for the msg: {}", msg) 
开发者ID:qxf2,项目名称:makemework,代码行数:18,代码来源:Base_Logging.py

示例2: scaffoldgraph_main

# 需要导入模块: from loguru import logger [as 别名]
# 或者: from loguru.logger import critical [as 别名]
def scaffoldgraph_main():
    """Run the CLI utility for ScaffoldGraph."""
    parser = scaffoldgraph_args()
    args = parser.parse_args(None if sys.argv[1:] else ['-h'])
    configure_logger(args.verbosity)
    try:
        args.func(args)
    except FileNotFoundError as e:
        logger.critical(f'Input file not found: {e.filename}')
    except ValueError as e:
        logger.critical(e)
    except RuntimeError as e:
        logger.critical(e)
    except MemoryError as e:
        logger.critical(e)
    except KeyboardInterrupt:
        logger.critical('scaffoldgraph process interrupted from keyboard')
    except Exception as e:
        logger.critical(f'Unknown error: {e}')
    finally:
        logger.info('Exiting scaffoldgraph...') 
开发者ID:UCLCheminformatics,项目名称:ScaffoldGraph,代码行数:23,代码来源:run.py

示例3: write

# 需要导入模块: from loguru import logger [as 别名]
# 或者: from loguru.logger import critical [as 别名]
def write(self,msg,level='info'):
        "Write out a message"
        #fname = inspect.stack()[2][3] #May be use a entry-exit decorator instead
        all_stack_frames = inspect.stack()
        for stack_frame in all_stack_frames[1:]:
            if 'Base_Page' not in stack_frame[1]:
                break
        fname = stack_frame[3]
        d = {'caller_func': fname}
        if hasattr(pytest,'config'):
            if pytest.config._config.getoption('--reportportal'):
                rp_logger = self.setup_rp_logging()
                if level.lower()== 'debug':
                    rp_logger.debug(msg=msg)
                elif level.lower()== 'info':
                    rp_logger.info(msg)
                elif level.lower()== 'warn' or level.lower()=='warning':
                    rp_logger.warning(msg)
                elif level.lower()== 'error':
                    rp_logger.error(msg)
                elif level.lower()== 'critical':
                    rp_logger.critical(msg)
                else:
                    rp_logger.critical(msg)
                return

        if level.lower()== 'debug':
            logger.debug("{module} | {msg}",module=d['caller_func'],msg=msg)
        elif level.lower()== 'info':
            logger.info("{module} | {msg}",module=d['caller_func'],msg=msg)
        elif level.lower()== 'warn' or level.lower()=='warning':
            logger.warning("{module} | {msg}",module=d['caller_func'],msg=msg)
        elif level.lower()== 'error':
            logger.error("{module} | {msg}",module=d['caller_func'],msg=msg)
        elif level.lower()== 'critical':
            logger.critical("{module} | {msg}",module=d['caller_func'],msg=msg)
        else:
            logger.critical("Unknown level passed for the msg: {}", msg) 
开发者ID:qxf2,项目名称:qxf2-page-object-model,代码行数:40,代码来源:Base_Logging.py

示例4: signals_to_exception

# 需要导入模块: from loguru import logger [as 别名]
# 或者: from loguru.logger import critical [as 别名]
def signals_to_exception(signals=(signal.SIGINT, signal.SIGTERM)):
    """Context manager that makes sure that converts system signals to exceptions.

    This allows for a graceful exit after receiving SIGTERM (e.g. through
    `kill` on UNIX systems).

    Example:
       >>> with signals_to_exception():
       >>>     try:
       >>>         # do something
       >>>     except SystemExit:
       >>>         # graceful exit even upon receiving interrupt signal
    """
    def signal_to_exception(sig, frame):
        logger.critical('Received interrupt signal {}', sig)
        raise SystemExit('Aborted')

    old_signals = {}
    for s in signals:
        # override signals with our handler
        old_signals[s] = signal.getsignal(s)
        signal.signal(s, signal_to_exception)

    try:
        yield

    finally:
        # re-attach old signals
        for s in signals:
            signal.signal(s, old_signals[s]) 
开发者ID:team-ocean,项目名称:veros,代码行数:32,代码来源:handlers.py

示例5: test_pickling_logging_method

# 需要导入模块: from loguru import logger [as 别名]
# 或者: from loguru.logger import critical [as 别名]
def test_pickling_logging_method(capsys):
    logger.add(print_, format="{level} - {function} - {message}")
    pickled = pickle.dumps(logger.critical)
    func = pickle.loads(pickled)
    func("A message")
    out, err = capsys.readouterr()
    assert out == "CRITICAL - test_pickling_logging_method - A message\n"
    assert err == "" 
开发者ID:Delgan,项目名称:loguru,代码行数:10,代码来源:test_pickling.py

示例6: get_xfrs_token

# 需要导入模块: from loguru import logger [as 别名]
# 或者: from loguru.logger import critical [as 别名]
def get_xfrs_token(page_html):
    """
    Method to parse a D2L page to find the XSRF.Token. The token is returned as a string
    :param page_html:
    :return:
    """
    soup = BeautifulSoup(page_html, "html.parser")
    # TODO Loop over all of them, as the location might change
    xsrf = str(soup.findAll("script")[0]).splitlines()
    token = None

    for line in xsrf:
        if "XSRF.Token" in line:  #
            line_soup = re.findall("'(.*?)'", line)
            # We can also find our User.ID in this line as well
            for i in range(0, len(line_soup)):
                if line_soup[i] == 'XSRF.Token':
                    token = line_soup[i + 1]
                    break

    if token is None:
        logger.critical("Cannot find XSRF.Token. Code might have changed")
        exit(1)
    logger.debug("Found XSRF.Token. It's {}".format(token))

    return token 
开发者ID:volfco,项目名称:MyCoursesDownloader,代码行数:28,代码来源:mycoursesdownloader.py


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