def _GetLogFormatter(program, multithreaded, debug, syslog):
  parts = []

  if syslog:
    parts.append(program + "[%(process)d]:")
  else:
    parts.append("%(asctime)s: " + program + " pid=%(process)d")

  if multithreaded:
    if syslog:
      parts.append(" (%(threadName)s)")
    else:
      parts.append("/%(threadName)s")

  # Add debug info for non-syslog loggers
  if debug and not syslog:
    parts.append(" %(module)s:%(lineno)s")

  # Ses, we do want the textual level, as remote syslog will probably lose the
  # error level, and it's easier to grep for it.
  parts.append(" %(levelname)s %(message)s")

  return logging.Formatter("".join(parts))
Build log formatter.
dataset/ETHPy150Open ganeti/ganeti/lib/utils/log.py/_GetLogFormatter