下面列出了org.slf4j.Marker#hasReferences ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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;
}
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;
}
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();
}
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;
}
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;
}