Did I find the right examples for you? yes no

All Samples(2)  |  Call(2)  |  Derive(0)  |  Import(0)
Configure a structuredlogger based on command line arguments.

:param suite: The name of the testsuite being run
:param args: A dictionary of {argument_name:value} produced from
             parsing the command line arguments for the application
:param defaults: A dictionary of {formatter name: output stream} to apply
                 when there is no logging supplied on the command line.

:rtype: StructuredLogger

        def setup_logging(suite, args, defaults):
    """
    Configure a structuredlogger based on command line arguments.

    :param suite: The name of the testsuite being run
    :param args: A dictionary of {argument_name:value} produced from
                 parsing the command line arguments for the application
    :param defaults: A dictionary of {formatter name: output stream} to apply
                     when there is no logging supplied on the command line.

    :rtype: StructuredLogger
    """
    logger = StructuredLogger(suite)
    prefix = "log_"
    found = False
    found_stdout_logger = False
    for name, values in args.iteritems():
        if name.startswith(prefix) and values is not None:
            for value in values:
                found = True
                if value == sys.stdout:
                    found_stdout_logger = True
                formatter_cls = log_formatters[name[len(prefix):]][0]
                logger.add_handler(handlers.StreamHandler(stream=value,
                                                          formatter=formatter_cls()))

    #If there is no user-specified logging, go with the default options
    if not found:
        for name, value in defaults.iteritems():
            formatter_cls = log_formatters[name][0]
            logger.add_handler(handlers.StreamHandler(stream=value,
                                                      formatter=formatter_cls()))

    elif not found_stdout_logger and sys.stdout in defaults.values():
        for name, value in defaults.iteritems():
            if value == sys.stdout:
                formatter_cls = log_formatters[name][0]
                logger.add_handler(handlers.StreamHandler(stream=value,
                                                          formatter=formatter_cls()))

    return logger
        


src/w/p/wptrunner-0.2.5/wptrunner/wptrunner.py   wptrunner(Download)
def setup_logging(args, defaults):
    global logger
    setup_compat_args(args)
    logger = commandline.setup_logging("web-platform-tests", args, defaults)
    setup_stdlib_logger()

src/w/p/wptrunner-0.2.5/wptrunner/reduce.py   wptrunner(Download)
def setup_logging(args, defaults):
    global logger
    logger = commandline.setup_logging("web-platform-tests-unstable", args, defaults)
    wptrunner.setup_stdlib_logger()