code: def write_logfile():
      # type: () -> None
      
      command = os.path.basename(os.path.realpath(os.path.abspath(sys.argv[0])))
      now = datetime.datetime.now().strftime('%Y%m%d-%H%M%S.%f')
      filename = '{}-{}.log'.format(command, now)
      with open(filename, 'w') as logfile:
          if six.PY3:
              logfile.write(_LOGFILE_STREAM.getvalue())
          else:
              logfile.write(_LOGFILE_STREAM.getvalue().decode(  # type: ignore
                  errors='replace'))
docs: Write a DEBUG log file COMMAND-YYYYMMDD-HHMMSS.ffffff.log.