Formats the specified field.

    Args:
      event (EventObject): event.
      field_name (str): name of the field.

    Returns:
      str: value of the field.
329993
def GetFormattedField(self, event, field_name):
    
    callback_name = self._FIELD_FORMAT_CALLBACKS.get(field_name, None)
    callback_function = None
    if callback_name:
      callback_function = getattr(self, callback_name, None)

    if callback_function:
      output_value = callback_function(event)
    else:
      output_value = getattr(event, field_name, '-')

    if output_value is None:
      output_value = '-'

    elif not isinstance(output_value, py2to3.STRING_TYPES):
      output_value = '{0!s}'.format(output_value)

    return output_value
611619
def format_value(obj, field_name):
    
    display_func = getattr(obj, 'get_%s_display' % field_name, None)
    if display_func:
        return display_func()
    value = getattr(obj, field_name)

    if isinstance(value, models.fields.files.FieldFile):
        if value:
            return mark_safe('<a href="%s">%s</a>' % (
                value.url,
                os.path.basename(value.name),
            ))
        else:
            return ''

    if isinstance(value, models.Model):
        return format_value_instance(value)

    if isinstance(value, models.Manager):
        return mark_safe(', '.join(
            [format_value_instance(instance) for instance in value.all()]
        ))
    if value is None:
        value = ""
    return value
717920
def format_field(self, value, format_spec):
        
        if format_spec:
            spec, arg = format_spec[0], format_spec[1:]
            arg = arg or None
        else:
            spec = arg = None
        return self._format_field(spec, arg, value, self.numeric_locale)
636721
def format(self, fmt, **kwargs):
        

        def compute(self):
            values = {}
            try:
                for name, field in kwargs.iteritems():
                    values[name] = reduce(getattr, field.split('.'), self.ctx.form)
            except AttributeError, ex:
                self.ctx.errors.invalid(str(ex))
                return ERROR
            return fmt.format(**values)

        return self.compute.attach(self)(compute)
1215132
public static String getJsonFieldName(Field field) {
        String name = field.getName();
        return Formatter.toCamelCase(name);
    }
1046716
@Override
  public  String getIndexName(Event event) {
    String realIndexPrefix = BucketPath.escapeString(event.getIndexPrefix() != null ? event.getIndexPrefix() : indexPrefix, event.getHeaders());
    if(event.getIndexTimestamp() != null){

      String indexName = new StringBuilder(realIndexPrefix).append('-')
              .append(event.getIndexTimestamp()).toString();
      if(logger.isDebugEnabled())
        logger.debug("Index Name = " + indexName);
      return indexName;
    }
    else {
      TimestampedEvent timestampedEvent = new TimestampedEvent(event);
      long timestamp = timestampedEvent.getTimestamp();
      String indexName = new StringBuilder(realIndexPrefix).append('-')
              .append(fastDateFormat.format(timestamp)).toString();
      if(logger.isDebugEnabled())
        logger.debug("Index Name = " + indexName);
      return indexName;
    }
  }
710769
public Object getValue(final String fieldName,
                         final LoggingEvent event) {
    String upperField = fieldName.toUpperCase(Locale.US);
    if (LOGGER_FIELD.equals(upperField)) {
      return event.getLoggerName();
    } else if (LEVEL_FIELD.equals(upperField)) {
      return event.getLevel();
    } else if (MSG_FIELD.equals(upperField)) {
      return event.getMessage();
    } else if (NDC_FIELD.equals(upperField)) {
      String ndcValue = event.getNDC();
      return ((ndcValue == null) ? EMPTY_STRING : ndcValue);
    } else if (EXCEPTION_FIELD.equals(upperField)) {
        String[] throwableRep = event.getThrowableStrRep();
        if (throwableRep == null) {
            return EMPTY_STRING;
        } else {
            return getExceptionMessage(throwableRep);
        }
    } else if (TIMESTAMP_FIELD.equals(upperField)) {
      return new Long(event.timeStamp);
    } else if (THREAD_FIELD.equals(upperField)) {
      return event.getThreadName();
    } else if (upperField.startsWith(PROP_FIELD)) {
      //note: need to use actual fieldname since case matters
      Object propValue = event.getMDC(fieldName.substring(5));
      if (propValue == null) {
          //case-specific match didn't work, try case insensitive match
          String lowerPropKey = fieldName.substring(5).toLowerCase();
          Set entrySet = event.getProperties().entrySet();
          for (Iterator iter = entrySet.iterator();iter.hasNext();) {
              Map.Entry thisEntry = (Map.Entry) iter.next();
              if (thisEntry.getKey().toString().equalsIgnoreCase(lowerPropKey)) {
                  propValue = thisEntry.getValue();
              }
          }
      }
      return ((propValue == null) ? EMPTY_STRING : propValue.toString());
    } else {
        LocationInfo info = event.getLocationInformation();
        if (CLASS_FIELD.equals(upperField)) {
            return ((info == null) ? EMPTY_STRING : info.getClassName());
        } else if (FILE_FIELD.equals(upperField)) {
            return ((info == null) ? EMPTY_STRING : info.getFileName());
        } else if (LINE_FIELD.equals(upperField)) {
            return ((info == null) ? EMPTY_STRING : info.getLineNumber());
        } else if (METHOD_FIELD.equals(upperField)) {
            return ((info == null) ? EMPTY_STRING : info.getMethodName());
        }
    }

    //there wasn't a match, so throw a runtime exception
    throw new IllegalArgumentException("Unsupported field name: " + fieldName);
  }
1159235
def format_json(event, colored):
        

        try:
            if event.message.startswith("{"):
                msg_dict = json.loads(event.message)
                event.message = json.dumps(msg_dict, indent=2)
        except Exception:
            # Skip if the event message was not JSON
            pass

        return event
721322
def _FormatMessage(self, event):
    
    message, _ = self._output_mediator.GetFormattedMessages(event)
    if message is None:
      data_type = getattr(event, 'data_type', 'UNKNOWN')
      raise errors.NoFormatterFound(
          'Unable to find event formatter for: {0:s}.'.format(data_type))

    return message
883579
def add_event(self, event):
        
        self._events.append(event)
        self._events_by_name[event.get_name] = event
309122
def _FormatUsername(self, event):
    
    username = self._output_mediator.GetUsername(event)
    return self._FormatField(username)
517467
def GetFormatStringAttributeNames(self, event):
    
    event_formatter = self.GetEventFormatter(event)
    if not event_formatter:
      return None

    return event_formatter.GetFormatStringAttributeNames()
844638
def _FormatInode(self, event):
    
    inode = event.inode
    if inode is None:
      if hasattr(event, 'pathspec') and hasattr(event.pathspec, 'image_inode'):
        inode = event.pathspec.image_inode
    if inode is None:
      inode = '-'

    return inode
1118881
def get_method_returning_field_value(self, field_name):
        
        method = getattr(self, field_name, None)
        return method if method and callable(method) else None
1338399
def _FormatSourceShort(self, event):
    
    source_short, _ = self._output_mediator.GetFormattedSources(event)
    if source_short is None:
      data_type = getattr(event, 'data_type', 'UNKNOWN')
      raise errors.NoFormatterFound(
          'Unable to find event formatter for: {0:s}.'.format(data_type))

    return source_short
784415
def get_dict_for_field(self, field_name):
        
        try:
            field = self.model._meta.get_field(field_name)
        except FieldDoesNotExist:
            field = None
        return {
            'label': self.get_field_label(field_name, field),
            'value': self.get_field_display_value(field_name, field),
        }
874005
def format( event )
      obj = format_obj(event.data)
      sprintf("%*s  %s : %s\n", ::Logging::MAX_LEVEL_LENGTH,
              ::Logging::LNAMES[event.level], event.logger, obj)
    end