Did I find the right examples for you? yes no

All Samples(2)  |  Call(2)  |  Derive(0)  |  Import(0)

        def std_logging_adapter(logger):
    """
    Adapter for stdlib logging so that it produces structured
    messages rather than standard logging messages

    :param logger: logging.Logger to wrap
    """
    global _wrapper_cls
    import logging

    if _wrapper_cls is not None:
        return _wrapper_cls(logger)

    class UnstructuredHandler(logging.Handler):
        def __init__(self, name=None, level=logging.NOTSET):
            self.structured = StructuredLogger(name)
            logging.Handler.__init__(self, level=level)

        def emit(self, record):
            if record.levelname in log_levels:
                log_func = getattr(self.structured, record.levelname.lower())
            else:
                log_func = self.logger.debug
            log_func(record.msg)

        def handle(self, record):
            self.emit(record)

    class LoggingWrapper(object):
        def __init__(self, wrapped):
            self.wrapped = wrapped
            self.wrapped.addHandler(UnstructuredHandler(self.wrapped.name,
                                                        logging.getLevelName(self.wrapped.level)))

        def add_handler(self, handler):
            self.addHandler(handler)

        def remove_handler(self, handler):
            self.removeHandler(handler)

        def __getattr__(self, name):
            return getattr(self.wrapped, name)

    _wrapper_cls = LoggingWrapper

    return LoggingWrapper(logger)
        


src/w/p/wptrunner-0.2.5/wptrunner/wptrunner.py   wptrunner(Download)
def setup_stdlib_logger():
    logging.root.handlers = []
    logging.root = structuredlog.std_logging_adapter(logging.root)
 
 

src/w/p/wptrunner-0.2.5/wptrunner/machlogging.py   wptrunner(Download)
        root_logger = logging.getLogger()
        if not hasattr(root_logger, "add_handler"):
            root_logger = structuredlog.std_logging_adapter(root_logger)
 
        self.structured_loggers = []