def end_logging(filename=None):
    """
    Close log file and restore system defaults.
    """

    if logutil.global_logging_started:
        if filename:
            print('Trailer file written to: ', filename)
        else:
            # This generally shouldn't happen if logging was started with
            # init_logging and a filename was given...
            print('No trailer file saved...')

        logutil.teardown_global_logging()
    else:
        print('No trailer file saved...')
Close log file and restore system defaults.