def configure_logger(name, log_stream=sys.stdout, log_file=None,<EOL>log_level=logging.INFO, keep_old_handlers=False,<EOL>propagate=False):
<EOL>logger = logging.getLogger(name)<EOL>logger.setLevel(log_level)<EOL>logger.propagate = propagate<EOL>if not keep_old_handlers:<EOL><INDENT>logger.handlers = []<EOL><DEDENT>log_fmt = '<STR_LIT>'<EOL>log_datefmt = '<STR_LIT>'<EOL>formatter = logging.Formatter(log_fmt, log_datefmt)<EOL>if log_stream is not None:<EOL><INDENT>stream_handler = logging.StreamHandler(log_stream)<EOL>stream_handler.setFormatter(formatter)<EOL>logger.addHandler(stream_handler)<EOL><DEDENT>if log_file is not None:<EOL><INDENT>file_handler = logging.FileHandler(log_file)<EOL>file_handler.setFormatter(formatter)<EOL>logger.addHandler(file_handler)<EOL><DEDENT>if log_stream is None and log_file is None:<EOL><INDENT>logger.addHandler(logging.NullHandler())<EOL><DEDENT>return logger<EOL>
Configures and returns a logger.

    This function serves to simplify the configuration of a logger that
    writes to a file and/or to a stream (e.g., stdout).

    Parameters
    ----------
    name: str
        The name of the logger. Typically set to ``__name__``.
    log_stream: a stream object, optional
        The stream to write log messages to. If ``None``, do not write to any
        stream. The default value is `sys.stdout`.
    log_file: str, optional
        The path of a file to write log messages to. If None, do not write to
        any file. The default value is ``None``.
    log_level: int, optional
        A logging level as `defined`__ in Python's logging module. The default
        value is `logging.INFO`.
    keep_old_handlers: bool, optional
        If set to ``True``, keep any pre-existing handlers that are attached to
        the logger. The default value is ``False``.
    propagate: bool, optional
        If set to ``True``, propagate the loggers messages to the parent
        logger. The default value is ``False``.

    Returns
    -------
    `logging.Logger`
        The logger.

    Notes
    -----
    Note that if ``log_stream`` and ``log_file`` are both ``None``, no handlers
    will be created.

    __ loglvl_

    .. _loglvl: https://docs.python.org/2/library/logging.html#logging-levels