@Override public String convert(ILoggingEvent event) { final Marker marker = event.getMarker(); return marker == null ? (event.getLevel() == null ? "" : event.getLevel().toString()) : marker.getName(); }
@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; }
void handle(final ILoggingEvent event) { final ProgramError error = addError( LogUtils.getErrorLevel(event.getLevel()), event.getFormattedMessage(), LogUtils.getThrowable(event), isAppError(event.getMarker())); handleErrorEvent(error); }
/** * 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); } } } } }
private boolean eventHasMarker(ILoggingEvent eventObject) { return eventObject.getMarker() != null; }