Configures the root logger for command line applications.

    A stream handler will be added to the logger that directs
    messages to the standard error stream.

    By default, *no* messages will be filtered out: set a higher
    level on derived/child loggers to achieve filtering.

    Warning
    -------
    Logging should only be configured once at the main entry point of the
    application!

def configure_logging(level=logging.DEBUG):
    '''Configures the root logger for command line applications.

    A stream handler will be added to the logger that directs
    messages to the standard error stream.

    By default, *no* messages will be filtered out: set a higher
    level on derived/child loggers to achieve filtering.

    Warning
    -------
    Logging should only be configured once at the main entry point of the
    application!
    '''
    fmt = '%(asctime)s | %(levelname)-8s | %(name)-40s | %(message)s'
    datefmt = '%Y-%m-%d %H:%M:%S'
    formatter = logging.Formatter(fmt=fmt, datefmt=datefmt)

    logger = logging.getLogger()  # returns the root logger

    stderr_handler = logging.StreamHandler(stream=sys.stderr)
    stderr_handler.name = 'err'
    stderr_handler.setLevel(level)
    stderr_handler.setFormatter(formatter)
    logger.addHandler(stderr_handler)