code: def setup_logging(debug, logfile=None):
      '''
      Setup logging format and log level.
      '''
      if debug:
          level = logging.DEBUG
      else:
          level = logging.INFO
      if logfile is not None:
          logging.basicConfig(format="%(asctime)s %(levelname)8s %(message)s", datefmt="%H:%M:%S %Y/%m/%d", level=level, filename=logfile)
      else:
          logging.basicConfig(format="%(asctime)s %(levelname)8s %(message)s", datefmt="%H:%M:%S %Y/%m/%d", level=levelf setup_logging(debug, logfile=None):
      '''
      Setup logging format and log level.
      '''
      if debug:
          level = logging.DEBUG
      else:
          level = logging.INFO
      if logfile is not None:
          logging.basicConfig(format="%(asctime)s %(levelname)8s %(message)s", datefmt="%H:%M:%S %Y/%m/%d", level=level, filename=logfile)
      else:
          logging.basicConfig(format="%(asctime)s %(levelname)8s %(message)s", datefmt="%H:%M:%S %Y/%m/%d", level=level)
docs: Setup logging format and log level.