Python logging.logProcesses() Examples

The following are code examples for showing how to use logging.logProcesses(). They are extracted from open source Python projects. You can vote up the examples you like or vote down the exmaples you don't like. You can also save this page to your account.

Example 1
Project: web_ctp   Author: molebot   File: test_logging.py    (license) View Source Project 6 votes vote down vote up
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 
Example 2
Project: ouroboros   Author: pybee   File: test_logging.py    (license) View Source Project 6 votes vote down vote up
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 
Example 3
Project: sdk-samples   Author: cradlepoint   File: log.py    (license) View Source Project 6 votes vote down vote up
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) 
Example 4
Project: kbe_server   Author: xiaohaoppy   File: test_logging.py    (license) View Source Project 6 votes vote down vote up
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 
Example 5
Project: stream2segment   Author: rizac   File: log.py    (license) View Source Project 6 votes vote down vote up
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)) 
Example 6
Project: nfvbench   Author: opnfv   File: log.py    (license) View Source Project 6 votes vote down vote up
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