當前位置: 首頁>>代碼示例>>Python>>正文


Python logging.logThreads方法代碼示例

本文整理匯總了Python中logging.logThreads方法的典型用法代碼示例。如果您正苦於以下問題:Python logging.logThreads方法的具體用法?Python logging.logThreads怎麽用?Python logging.logThreads使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在logging的用法示例。


在下文中一共展示了logging.logThreads方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: config_logging

# 需要導入模塊: import logging [as 別名]
# 或者: from logging import logThreads [as 別名]
def config_logging(level=LEVEL, prefix=PREFIX, other_loggers=None):
    # Little speed up
    if "%(process)d" not in prefix:
        logging.logProcesses = False
    if "%(processName)s" not in prefix:
        logging.logMultiprocessing = False
    if "%(thread)d" not in prefix and "%(threadName)s" not in prefix:
        logging.logThreads = False
    handler = logging.StreamHandler()
    handler.setFormatter(LogFormatter())
    loggers = [logging.getLogger('pyftpdlib')]
    if other_loggers is not None:
        loggers.extend(other_loggers)
    for logger in loggers:
        logger.setLevel(level)
        logger.addHandler(handler) 
開發者ID:aliyun,項目名稱:oss-ftp,代碼行數:18,代碼來源:log.py

示例2: test_optional

# 需要導入模塊: import logging [as 別名]
# 或者: from logging import logThreads [as 別名]
def test_optional(self):
        r = logging.makeLogRecord({})
        NOT_NONE = self.assertIsNotNone
        if threading:
            NOT_NONE(r.thread)
            NOT_NONE(r.threadName)
        NOT_NONE(r.process)
        NOT_NONE(r.processName)
        log_threads = logging.logThreads
        log_processes = logging.logProcesses
        log_multiprocessing = logging.logMultiprocessing
        try:
            logging.logThreads = False
            logging.logProcesses = False
            logging.logMultiprocessing = False
            r = logging.makeLogRecord({})
            NONE = self.assertIsNone
            NONE(r.thread)
            NONE(r.threadName)
            NONE(r.process)
            NONE(r.processName)
        finally:
            logging.logThreads = log_threads
            logging.logProcesses = log_processes
            logging.logMultiprocessing = log_multiprocessing 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:27,代碼來源:test_logging.py

示例3: logf

# 需要導入模塊: import logging [as 別名]
# 或者: from logging import logThreads [as 別名]
def logf(logger_func):
    @wraps(logger_func)
    def log_wrapper(*args):
        if DEBUG:
            logProcesses = logging.logProcesses
            logThreads = logging.logThreads
            logMultiprocessing = logging.logMultiprocessing
            logging.logThreads = logging.logProcesses = logMultiprocessing = False
            # disable logging pids and tids - we don't want extra calls around, especilly when we monkeypatch stuff
            try:
                return logger_func(*args)
            finally:
                logging.logProcesses = logProcesses
                logging.logThreads = logThreads
                logging.logMultiprocessing = logMultiprocessing
    return log_wrapper 
開發者ID:ionelmc,項目名稱:python-aspectlib,代碼行數:18,代碼來源:utils.py

示例4: config_logging

# 需要導入模塊: import logging [as 別名]
# 或者: from logging import logThreads [as 別名]
def config_logging(level=LEVEL, prefix=PREFIX, other_loggers=None):
    # Little speed up
    if "(process)" not in prefix:
        logging.logProcesses = False
    if "%(processName)s" not in prefix:
        logging.logMultiprocessing = False
    if "%(thread)d" not in prefix and "%(threadName)s" not in prefix:
        logging.logThreads = False
    handler = logging.StreamHandler()
    formatter = LogFormatter()
    formatter.PREFIX = prefix
    handler.setFormatter(formatter)
    loggers = [logging.getLogger('pyftpdlib')]
    if other_loggers is not None:
        loggers.extend(other_loggers)
    for logger in loggers:
        logger.setLevel(level)
        logger.addHandler(handler) 
開發者ID:giampaolo,項目名稱:pyftpdlib,代碼行數:20,代碼來源:log.py

示例5: create_logger

# 需要導入模塊: import logging [as 別名]
# 或者: from logging import logThreads [as 別名]
def create_logger(level=logging.NOTSET):
    """Create a logger for python-gnupg at a specific message level.

    :type level: :obj:`int` or :obj:`str`
    :param level: A string or an integer for the lowest level to include in
                  logs.

    **Available levels:**

    ==== ======== ========================================
    int   str     description
    ==== ======== ========================================
    0    NOTSET   Disable all logging.
    9    GNUPG    Log GnuPG's internal status messages.
    10   DEBUG    Log module level debuging messages.
    20   INFO     Normal user-level messages.
    30   WARN     Warning messages.
    40   ERROR    Error messages and tracebacks.
    50   CRITICAL Unhandled exceptions and tracebacks.
    ==== ======== ========================================
    """
    _test = os.path.join(os.path.join(os.getcwd(), 'gnupg'), 'test')
    _now  = datetime.now().strftime("%Y-%m-%d_%H%M%S")
    _fn   = os.path.join(_test, "%s_test_gnupg.log" % _now)
    _fmt  = "%(relativeCreated)-4d L%(lineno)-4d:%(funcName)-18.18s %(levelname)-7.7s %(message)s"

    ## Add the GNUPG_STATUS_LEVEL LogRecord to all Loggers in the module:
    logging.addLevelName(GNUPG_STATUS_LEVEL, "GNUPG")
    logging.Logger.status = status

    if level > logging.NOTSET:
        logging.basicConfig(level=level, filename=_fn,
                            filemode="a", format=_fmt)
        logging.logThreads = True
        if hasattr(logging,'captureWarnings'):
            logging.captureWarnings(True)
        colouriser = _ansistrm.ColorizingStreamHandler
        colouriser.level_map[9]  = (None, 'blue', False)
        colouriser.level_map[10] = (None, 'cyan', False)
        handler = colouriser(sys.stderr)
        handler.setLevel(level)

        formatr = logging.Formatter(_fmt)
        handler.setFormatter(formatr)
    else:
        handler = NullHandler()

    log = logging.getLogger('gnupg')
    log.addHandler(handler)
    log.setLevel(level)
    log.info("Log opened: %s UTC" % datetime.ctime(datetime.utcnow()))
    return log 
開發者ID:PaperDashboard,項目名稱:shadowsocks,代碼行數:54,代碼來源:_logger.py


注:本文中的logging.logThreads方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。