code: def setup_logger(log_dir=None, loglevel=logging.DEBUG):
      
  
      create_home_dir()
      create_dir(os.path.join(get_default_home_dir(), 'log'))
  
      if log_dir is None:
          log_dir = os.path.join(get_default_home_dir(), 'log')
  
      logger = logging.getLogger('ding0') # use filename as name in log
      logger.setLevel(loglevel)
  
      # create a file handler
      handler = logging.FileHandler(os.path.join(log_dir, 'ding0.log'))
      handler.setLevel(logging.DEBUG)
      formatter = logging.Formatter(
          '%(asctime)s-%(funcName)s-%(message)s (%(levelname)s)')
      handler.setFormatter(formatter)
  
      # create a stream handler (print to prompt)
      stream = logging.StreamHandler()
      stream.setLevel(logging.INFO)
      stream_formatter = logging.Formatter(
          '%(message)s (%(levelname)s)')
      stream.setFormatter(stream_formatter)
  
      # add the handlers to the logger
      logger.addHandler(handler)
      logger.addHandler(stream)
  
      logger.info('########## New run of Ding0 issued #############')
  
      return logger
docs: Instantiate logger
  
      Parameters
      ----------
      log_dir: str
          Directory to save log, default: ~/.ding0/logging/
      loglevel: 
          Level of logger.