code: def set_dir(dirname):
      global LOG_DIR, _FILE_HANDLER, _logger
      if _FILE_HANDLER:
          # unload and close the old file handler, so that we may safely delete the logger directory
          _logger.removeHandler(_FILE_HANDLER)
          _FILE_HANDLER.close()
          del _FILE_HANDLER
  
      shutil.rmtree(dirname, ignore_errors=True)
      _makedirs(dirname)
      LOG_DIR = dirname
      _set_file(os.path.join(dirname, "log.log"))
  
imports: import errno
  import logging
  import os
  import os.path
  import sys
  from termcolor import colored
  import shutil
  from datetime import datetime
label_desc: Use image node_id 6 for calling a global function with example usage: set_dir(dirname) without return types