Java Code Examples for org.slf4j.Marker#hasReferences()

The following examples show how to use org.slf4j.Marker#hasReferences() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Log4jMarkerFactory.java    From logging-log4j2 with Apache License 2.0 6 votes vote down vote up
private static org.apache.logging.log4j.Marker convertMarker(final Marker original,
                                                             final Collection<Marker> visited) {
    final org.apache.logging.log4j.Marker marker = MarkerManager.getMarker(original.getName());
    if (original.hasReferences()) {
        final Iterator<Marker> it = original.iterator();
        while (it.hasNext()) {
            final Marker next = it.next();
            if (visited.contains(next)) {
                LOGGER.warn("Found a cycle in Marker [{}]. Cycle will be broken.", next.getName());
            } else {
                visited.add(next);
                marker.addParents(convertMarker(next, visited));
            }
        }
    }
    return marker;
}
 
Example 2
Source File: Log4jMarkerFactory.java    From logging-log4j2 with Apache License 2.0 6 votes vote down vote up
private static org.apache.logging.log4j.Marker convertMarker(final Marker original,
                                                             final Collection<Marker> visited) {
    final org.apache.logging.log4j.Marker marker = MarkerManager.getMarker(original.getName());
    if (original.hasReferences()) {
        final Iterator<Marker> it = original.iterator();
        while (it.hasNext()) {
            final Marker next = it.next();
            if (visited.contains(next)) {
                LOGGER.warn("Found a cycle in Marker [{}]. Cycle will be broken.", next.getName());
            } else {
                visited.add(next);
                marker.addParents(convertMarker(next, visited));
            }
        }
    }
    return marker;
}
 
Example 3
Source File: GelfEncoder.java    From logback-gelf with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static String buildMarkerStr(final Marker marker) {
    if (!marker.hasReferences()) {
        return marker.getName();
    }

    final StringBuilder sb = new StringBuilder(marker.getName());

    final Iterator<Marker> it = marker.iterator();
    do {
        sb.append(", ").append(it.next().getName());
    } while (it.hasNext());

    return sb.toString();
}
 
Example 4
Source File: SecurityMarkerFilter.java    From owasp-security-logging with Apache License 2.0 5 votes vote down vote up
public FilterReply decide(ILoggingEvent event) {
	if (!isStarted()) {
		return FilterReply.NEUTRAL;
	}

	// make sure the event has a marker
	Marker eventMarker = event.getMarker();

	if (eventMarker == null) {
		return FilterReply.DENY;
	}

	if (eventMarker.hasReferences()) {
		// check for events with multiple markers
		for (Marker marker : markersToMatch) {
			if (eventMarker.contains(marker)) {
				return acceptAll ? FilterReply.ACCEPT : FilterReply.NEUTRAL;
			}
		}
	} else {
		// handle simple case of an event with a single marker
		if (markersToMatch.contains(eventMarker)) {
			return acceptAll ? FilterReply.ACCEPT : FilterReply.NEUTRAL;
		}
	}

	// no match found for security markers
	return FilterReply.DENY;
}
 
Example 5
Source File: ExcludeClassifiedMarkerFilter.java    From owasp-security-logging with Apache License 2.0 5 votes vote down vote up
public FilterReply decide(ILoggingEvent event) {
	if (!isStarted()) {
		return FilterReply.NEUTRAL;
	}

	// make sure the event has a marker
	Marker eventMarker = event.getMarker();
	if (eventMarker == null) {
		return FilterReply.NEUTRAL;
	}

	if (eventMarker.hasReferences()) {
		// check for events with multiple markers
		for (Marker marker : markersToMatch) {
			if (eventMarker.contains(marker)) {
				return FilterReply.DENY;
			}
		}
	} else {
		// handle simple case of an event with a single marker
		if (markersToMatch.contains(eventMarker)) {
			return FilterReply.DENY;
		}
	}

	// no classified markers found
	return FilterReply.NEUTRAL;
}