當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。