Return a copy of the DEFAULT_LOGGING config with installed application
    loggers at the given log level.  The 'default' handler is kept as a
    console/stream writer unless a filename is passed in, which swaps the stream
    handler out for a file handler.  The 'verbose' formatter is used if
    verbosity is enabled.

def _build_logging_config(level, apps_list, verbose, filename=None):
    """ Return a copy of the DEFAULT_LOGGING config with installed application
    loggers at the given log level.  The 'default' handler is kept as a
    console/stream writer unless a filename is passed in, which swaps the stream
    handler out for a file handler.  The 'verbose' formatter is used if
    verbosity is enabled. """
    config = copy.deepcopy(DEFAULT_LOGGING)

    # Swap out default stream handler for a file handler, if
    # a filename is given
    if filename:
        config['handlers']['default'].update(
            {
                'class': 'logging.handlers.WatchedFileHandler',
                'filename': filename,
            }
        )

    if verbose:
        config['handlers']['default']['formatter'] = 'verbose'

    config['loggers'] = build_app_loggers(level, apps_list)

    return config