def ConfigureLogging(debug_level=logging.INFO,
                     show_level=True,
                     stderr=True,
                     syslog=True,
                     facility=None):
  if not stderr and not syslog:
    raise LogConfigurationError('Neither syslog nor stdout handlers set.')

  if facility and not syslog:
    raise LogConfigurationError('facility can only be used with syslog.')

  logger = logging.getLogger()

  # Clear any existing handlers
  logger.handlers = []

  logger.setLevel(debug_level)
  if syslog:
    # Get the default syslog facility
    facility_id = logging.handlers.SysLogHandler.LOG_USER
    if facility:
      try:
        facility_id = logging.handlers.SysLogHandler.facility_names[facility]
      except KeyError:
        logging.error('%s is an invalid facility, using default.', facility)
    try:
      syslog_handler = MultilineSysLogHandler(facility=facility_id)
      _ConfigureHandler(syslog_handler, logger, LOG_FORMAT_SYSLOG, debug_level)
    except socket.error:
      print >>sys.stderr, 'Warning: Could not configure syslog based logging.'
      stderr = True

  if stderr:
    stderr_handler = logging.StreamHandler()
    if show_level:
      _ConfigureHandler(stderr_handler, logger, LOG_FORMAT_STDERR_LEVEL,
                        debug_level)
    else:
      _ConfigureHandler(stderr_handler, logger, LOG_FORMAT_STDERR, debug_level)

  logging.debug('Logging enabled at level %s', debug_level)
Checks if a tablespace exists on the Postgres server.
dataset/ETHPy150Open google/macops/gmacpyutil/gmacpyutil/gmacpyutil.py/ConfigureLogging--crossover with--dataset/ETHPy150Open saltstack/salt/salt/modules/postgres.py/tablespace_exists