<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 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...')