Python logging 模块,logProcesses() 实例源码

我们从Python开源项目中,提取了以下6个代码示例,用于说明如何使用logging.logProcesses()

项目:web_ctp    作者:molebot    | 项目源码 | 文件源码
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
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
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
项目:sdk-samples    作者:cradlepoint    | 项目源码 | 文件源码
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)
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
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
项目:stream2segment    作者:rizac    | 项目源码 | 文件源码
def configlog4download(logger, db_session, download_id, isterminal):
    """configs for download and returns the handler used to store the log to the db
    and to a tmp file. The file is accessible via logger..baseFilename
    """
    # https://docs.python.org/2/howto/logging.html#optimization:
    logging._srcfile = None
    logging.logThreads = 0
    logging.logProcesses = 0
    # FIXME above: move elsewhere (maybe restoring defaults?)
    logger.setLevel(logging.INFO)  # necessary to forward to handlers
    # custom StreamHandler: count errors and warnings:
    dbstream_handler = DbStreamHandler(db_session, download_id)
    logger.addHandler(dbstream_handler)
    if isterminal:
        # configure print to stdout (by default only info and critical messages)
        logger.addHandler(SysOutStreamHandler(sys.stdout))
    return dbstream_handler


# def configlog4stdout(logger):
#     logger.setLevel(logging.INFO)  # necessary to forward to handlers
#     # configure print to stdout (by default only info and critical messages):
#     logger.addHandler(SysOutStreamHandler(sys.stdout))
项目:nfvbench    作者:opnfv    | 项目源码 | 文件源码
def setup(mute_stdout=False):
    # logging.basicConfig()
    if mute_stdout:
        handler = logging.NullHandler()
    else:
        formatter_str = '%(asctime)s %(levelname)s %(message)s'
        handler = logging.StreamHandler()
        handler.setFormatter(logging.Formatter(formatter_str))

    # Add handler to logger
    logger = logging.getLogger(_product_name)
    logger.addHandler(handler)
    # disable unnecessary information capture
    logging.logThreads = 0
    logging.logProcesses = 0
    # to make sure each log record does not have a source file name attached
    # pylint: disable=protected-access
    logging._srcfile = None
    # pylint: enable=protected-access