Gets the formatter for the logs generated by handleBatch().
503050
public function getBatchFormatter(): FormatterInterface
    {
        if (!$this->batchFormatter) {
            $this->batchFormatter = $this->getDefaultBatchFormatter();
        }

        return $this->batchFormatter;
    }
198810
def get_formatter(name):
    
    if name in ('self', 'instance', 'this'):
        return af_self
    elif name == 'class':
        return af_class
    elif name in ('named', 'param', 'parameter'):
        return af_named
    elif name in ('default', 'optional'):
        return af_default
#    elif name in ('anonymous', 'arbitrary', 'unnamed'):
#        return af_anonymous
    elif name in ('keyword', 'pair', 'pairs'):
        return af_keyword
    else:
        raise ValueError('unknown trace formatter %r' % name)
909736
def log_formatter(request=None):
    

    if request:
        format_str = ('%(asctime)s {ip} {name}:  ENV={env} '
                      'REMOTE_IP=%(remote_ip)s REQUEST_ID=%(request_id)s '
                      '%(message)s')
    else:
        format_str = '%(asctime)s {ip} {name}:  ENV={env} %(message)s'

    try:
        hostname = socket.gethostname()
    except socket.gaierror:
        hostname = 'localhost'

    try:
        ip = socket.gethostbyname(hostname)
    except socket.gaierror:
        ip = '127.0.0.1'

    formatter = logging.Formatter(
            format_str.format(ip=ip, name=options.name, env=options.env),
            datefmt='%Y-%m-%dT%H:%M:%S')
    logging.Formatter.converter = time.gmtime

    return formatter
847918
def _get_formatter(fmt):
    
    fmt = _replace_and_pad(fmt, "%(timezone)s", LogManager.spec.timezone)
    return logging.Formatter(fmt)
619418
protected String formatVersionInfo() {
    Formatter formatter = new Formatter();
    formatter.format("TraceLogger[%s]: Version = %s.", this.name, VERSION);

    return formatter.toString();
  }
827832
def get_logger(name=None):
    

    level = logging.CRITICAL
    if DEBUG:
        logging.disable(logging.NOTSET)
        level = logging.DEBUG

    if name is None:
        name = "<unknown>"

    log = logging.getLogger(name=name)
    log.setLevel( level )
    console = logging.StreamHandler()
    console.setLevel( level )
    log_format = ('[%(asctime)s] [%(levelname)s] [%(module)s:%(lineno)d] (' + str(os.getpid()) + '.%(thread)d) %(message)s' if DEBUG else '%(message)s')
    formatter = logging.Formatter( log_format )
    console.setFormatter(formatter)
    log.propagate = False

    if len(log.handlers) > 0:
        for i in xrange(0, len(log.handlers)):
            log.handlers.pop(0)
    
    log.addHandler(console)
    return log
1250155
@Override
	public String format (LogRecord logRecord) {
		StringBuilder resultBuilder = new StringBuilder ();
		String prefix = logRecord.getLevel ().getName () + "\t";

		resultBuilder.append (prefix);

		resultBuilder.append (Thread.currentThread ().getName ())
				.append (" ")
				.append (sdf.format (new java.util.Date (logRecord.getMillis ())))
				.append (": ")
				.append (logRecord.getSourceClassName ())
				.append (":")
				.append (logRecord.getSourceMethodName ())
				.append (": ")
				.append (logRecord.getMessage ());

		Object[] params = logRecord.getParameters ();
		if (params != null) {
			resultBuilder.append ("\nParameters:");

			if (params.length < 1) {
				resultBuilder.append (" (none)");
			} else {
				for (int paramIndex = 0; paramIndex < params.length; paramIndex++) {
					Object param = params[paramIndex];
					if (param != null) {
						String paramString = param.toString ();

						resultBuilder.append ("\nParameter ")
								.append (String.valueOf (paramIndex))
								.append (" is a ")
								.append (param.getClass ().getName ())
								.append (": >")
								.append (paramString)
								.append ("<");
					} else {
						resultBuilder.append ("\nParameter ")
								.append (String.valueOf (paramIndex))
								.append (" is null.");
					}
				}
			}
		}

		Throwable t = logRecord.getThrown ();
		if (t != null) {
			resultBuilder.append ("\nThrowing:\n")
					.append (getFullThrowableMsg (t));
		}
		
		String result = resultBuilder.toString ().replaceAll ("\n", "\n" + prefix) + "\n";

		return result;
	}
318207
public function getLoggingFormatter()
    {
        if (null === $this->loggingFormatter) {
            @trigger_error(sprintf('The %s() method is deprecated since Symfony 3.3 and will be removed in 4.0. Use the ContainerBuilder::log() method instead.', __METHOD__), E_USER_DEPRECATED);

            $this->loggingFormatter = new LoggingFormatter();
        }

        return $this->loggingFormatter;
    }
829332
def _get_logging_id(self):
        """"""
        return "{}.{}/{}".format(
            self._request.viewset_class.__module__,
            self._request.viewset_class.__name__,
            self._request.viewset_method,
        )
87259
def getLoggerWithConsoleHandler(logger_name=None):
    
    logger = logging.getLogger(logger_name)
    logger.setLevel(logging.INFO)
    if not logger.handlers:
        handler = logging.StreamHandler(sys.stdout)
        if sys.platform == 'win32':
            formatter = logging.Formatter(
                            fmt="%(asctime)s %(name)s %(message)s",
                            datefmt='%H:%M:%S')
        else:
            formatter = ColorFormatter(fmt="$RESET %(asctime)s "
                                       "$BOLD$COLOR%(name)s$RESET "
                                       "%(message)s", datefmt='%H:%M:%S')
        handler.setFormatter(formatter)
        logger.addHandler(handler)
    return logger
1297906
def formatter(self):
        
        formatter_chain = [
            LambdaLogMsgFormatters.colorize_errors,

            # Format JSON "before" highlighting the keywords. Otherwise, JSON will be invalid from all the
            # ANSI color codes and fail to pretty print
            JSONMsgFormatter.format_json,

            KeywordHighlighter(self._filter_pattern).highlight_keywords,
        ]

        return LogsFormatter(self.colored, formatter_chain)
1140944
public static Format getFormatter(@Nonnull final Locale locale, @Nonnull final String format,
                                      @Nullable final Class<?>... type) {
        Format formatter = null;
        Pattern TEXT_FORMAT_STRING = Pattern.compile("^\\{([^}]+)}(.+)$");
        Matcher matcher = TEXT_FORMAT_STRING.matcher(format);
        if (matcher.matches()) {
            switch (matcher.group(1)) {
                case "Message":
                    formatter = new MessageFormat(matcher.group(2), locale);
                    break;
                case "Date":
                    formatter = new SimpleDateFormat(matcher.group(2), locale);
                    break;
                case "String":
                    formatter = new FormatterFormat(matcher.group(2), locale);
                    break;
                default:
                case "Log":
                    formatter = new LoggerFormat(matcher.group(2));
                    break;
            }
        } else {
            if (type != null && type.length == 1 && type[0] != null &&
                    (Calendar.class.isAssignableFrom(type[0]) || Date.class.isAssignableFrom(type[0]))) {
                formatter = new SimpleDateFormat(format, locale);
            } else {
                formatter = new LoggerFormat(format);
            }
        }
        return formatter;
    }
545431
public static Formatter getFormatter()
    {
        Formatter formatter = out.get();
        if (formatter == null)
        {
            formatter = new Formatter(new StringBuilder());
            out.set(formatter);
        }
        else
        {
            StringBuilder sb = (StringBuilder) formatter.out();
            sb.setLength(0);
        }
        return formatter;
    }
1060936
def getCustomLogger(name, logLevel, logFormat='%(asctime)s %(levelname)-9s:%(name)s:%(module)s:%(funcName)s: %(message)s'):
  '''
  
  '''
  assert isinstance(logFormat, basestring), ("logFormat must be a string but is %r" % logFormat)
  assert isinstance(logLevel, basestring), ("logLevel must be a string but is %r" % logLevel)
  assert isinstance(name, basestring), ("name must be a string but is %r" % name)

  validLogLevels = ['CRITICAL', 'DEBUG', 'ERROR', 'INFO', 'WARNING']

  if not logLevel:
    logLevel = 'DEBUG'

  # If they don't specify a valid log level, err on the side of verbosity
  if logLevel.upper() not in validLogLevels:
    logLevel = 'DEBUG'

  numericLevel = getattr(logging, logLevel.upper(), None)
  if not isinstance(numericLevel, int):
    raise ValueError("Invalid log level: %s" % logLevel)

  logging.basicConfig(level=numericLevel, format=logFormat)
  logger = logging.getLogger(name)
  return logger
182372
def extract_formats(config_handle):
    
    configurations = dict(config_handle)
    formats = dict(configurations.get('formats', {}))
    return formats
146417
def format(self, record):
        
        out = dict(
            Timestamp=int(record.created * 1e9),
            Type=record.name,
            Logger=self.logger_name,
            Hostname=self.hostname,
            EnvVersion=self.LOGGING_FORMAT_VERSION,
            Severity=self.SYSLOG_LEVEL_MAP.get(record.levelno,
                                               self.DEFAULT_SYSLOG_LEVEL),
            Pid=record.process,
        )

        # Include any custom attributes set on the record.
        # These would usually be collected metrics data.
        fields = dict()
        for key, value in record.__dict__.items():
            if key not in self.EXCLUDED_LOGRECORD_ATTRS:
                fields[key] = value

        # Only include the 'message' key if it has useful content
        # and is not already a JSON blob.
        message = record.getMessage()
        if message:
            if not message.startswith("{") and not message.endswith("}"):
                fields["msg"] = message

        # If there is an error, format it for nice output.
        if record.exc_info is not None:
            fields["error"] = repr(record.exc_info[1])
            fields["traceback"] = safer_format_traceback(*record.exc_info)

        out['Fields'] = fields

        return json.dumps(out)
37134
def format_log(ret):
    '''
    
    '''
    msg = ''
    if isinstance(ret, dict):
        # Looks like the ret may be a valid state return
        if 'changes' in ret:
            # Yep, looks like a valid state return
            chg = ret['changes']
            if not chg:
                if ret['comment']:
                    msg = ret['comment']
                else:
                    msg = 'No changes made for {0[name]}'.format(ret)
            elif isinstance(chg, dict):
                if 'diff' in chg:
                    if isinstance(chg['diff'], six.string_types):
                        msg = 'File changed:\n{0}'.format(chg['diff'])
                if all([isinstance(x, dict) for x in six.itervalues(chg)]):
                    if all([('old' in x and 'new' in x)
                            for x in six.itervalues(chg)]):
                        msg = 'Made the following changes:\n'
                        for pkg in chg:
                            old = chg[pkg]['old']
                            if not old and old not in (False, None):
                                old = 'absent'
                            new = chg[pkg]['new']
                            if not new and new not in (False, None):
                                new = 'absent'
                            # This must be able to handle unicode as some package names contain
                            # non-ascii characters like "Français" or "Español". See Issue #33605.
                            msg += '\'{0}\' changed from \'{1}\' to \'{2}\'\n'.format(pkg, old, new)
            if not msg:
                msg = six.text_type(ret['changes'])
            if ret['result'] is True or ret['result'] is None:
                log.info(msg)
            else:
                log.error(msg)
    else:
        # catch unhandled data
        log.info(six.text_type(ret))