示例#1
0
 @Override
 public String convert(ILoggingEvent event) {
   final Marker marker = event.getMarker();
   return marker == null
       ? (event.getLevel() == null ? "" : event.getLevel().toString())
       : marker.getName();
 }
示例#2
0
 @Override
 public FilterReply decide(ILoggingEvent event) {
   Marker marker = event.getMarker();
   if (!isStarted()) return FilterReply.NEUTRAL;
   if (null == marker) return onMismatch;
   if (markerToMatch.contains(marker)) return onMatch;
   return onMismatch;
 }
示例#3
0
 void handle(final ILoggingEvent event) {
   final ProgramError error =
       addError(
           LogUtils.getErrorLevel(event.getLevel()),
           event.getFormattedMessage(),
           LogUtils.getThrowable(event),
           isAppError(event.getMarker()));
   handleErrorEvent(error);
 }
示例#4
0
  /**
   * Converts the additional fields into proper GELF JSON
   *
   * @param map The map of additional fields
   * @param eventObject The Logging event that we are converting to GELF
   */
  private void additionalFields(Map<String, Object> map, ILoggingEvent eventObject) {

    if (useLoggerName) {
      map.put("_loggerName", eventObject.getLoggerName());
    }

    if (useMarker && eventHasMarker(eventObject)) {
      map.put("_marker", eventObject.getMarker().toString());
    }

    if (useThreadName) {
      map.put("_threadName", eventObject.getThreadName());
    }

    Map<String, String> mdc = eventObject.getMDCPropertyMap();

    if (mdc != null) {

      if (includeFullMDC) {
        for (Entry<String, String> e : mdc.entrySet()) {
          if (additionalFields.containsKey(e.getKey())) {
            map.put(additionalFields.get(e.getKey()), e.getValue());
          } else {
            map.put("_" + e.getKey(), e.getValue());
          }
        }
      } else {
        for (String key : additionalFields.keySet()) {
          String field = mdc.get(key);
          if (field != null) {
            map.put(additionalFields.get(key), field);
          }
        }
      }
    }
  }
示例#5
0
 private boolean eventHasMarker(ILoggingEvent eventObject) {
   return eventObject.getMarker() != null;
 }