org.apache.logging.log4j.Marker.isInstanceOf()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(118)

本文整理了Java中org.apache.logging.log4j.Marker.isInstanceOf()方法的一些代码示例,展示了Marker.isInstanceOf()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Marker.isInstanceOf()方法的具体详情如下:
包路径:org.apache.logging.log4j.Marker
类名称:Marker
方法名:isInstanceOf

Marker.isInstanceOf介绍

[英]Checks whether this Marker is an instance of the specified Marker.
[中]检查此标记是否为指定标记的实例。

代码示例

代码示例来源:origin: org.apache.logging.log4j/log4j-slf4j-impl

@Override
public boolean contains(final String s) {
  return s != null ? this.marker.isInstanceOf(s) : false;
}

代码示例来源:origin: org.apache.logging.log4j/log4j-slf4j-impl

@Override
public boolean contains(final org.slf4j.Marker marker) {
  if (marker == null) {
    throw new IllegalArgumentException();
  }
  return this.marker.isInstanceOf(marker.getName());
}

代码示例来源:origin: org.apache.logging.log4j/log4j-api

if (localParents != null) {
  for (final Marker parent : parentMarkers) {
    if (!(contains(parent, localParents) || parent.isInstanceOf(this))) {
      ++count;
  if (localParents == null || !(contains(parent, localParents) || parent.isInstanceOf(this))) {
    markers[index++] = parent;

代码示例来源:origin: org.apache.logging.log4j/log4j-api

@Test
public void testMultipleParents() {
  final Marker parent1 = MarkerManager.getMarker("PARENT1");
  final Marker parent2 = MarkerManager.getMarker("PARENT2");
  final Marker test1 = MarkerManager.getMarker("TEST1").setParents(parent1, parent2);
  final Marker test2 = MarkerManager.getMarker("TEST2").addParents(parent1, parent2);
  assertTrue("TEST1 is not an instance of PARENT1", test1.isInstanceOf(parent1));
  assertTrue("TEST1 is not an instance of PARENT2", test1.isInstanceOf(parent2));
  assertTrue("TEST2 is not an instance of PARENT1", test2.isInstanceOf(parent1));
  assertTrue("TEST2 is not an instance of PARENT2", test2.isInstanceOf(parent2));
}

代码示例来源:origin: org.apache.logging.log4j/log4j-api

@Test
public void testAddToExistingParents() {
  final Marker parent = MarkerManager.getMarker("PARENT");
  final Marker existing = MarkerManager.getMarker("EXISTING");
  final Marker test1 = MarkerManager.getMarker("TEST1").setParents(existing);
  test1.addParents(parent);
  assertTrue("TEST1 is not an instance of PARENT", test1.isInstanceOf(parent));
  assertTrue("TEST1 is not an instance of EXISTING", test1.isInstanceOf(existing));
}

代码示例来源:origin: org.apache.logging.log4j/log4j-api

@Test
public void testMarker() {
  final Marker parent = MarkerManager.getMarker("PARENT");
  final Marker test1 = MarkerManager.getMarker("TEST1").setParents(parent);
  final Marker test2 = MarkerManager.getMarker("TEST2").addParents(parent);
  assertTrue("TEST1 is not an instance of PARENT", test1.isInstanceOf(parent));
  assertTrue("TEST2 is not an instance of PARENT", test2.isInstanceOf(parent));
}

代码示例来源:origin: org.apache.logging.log4j/log4j-slf4j-impl

@Test
public void testAddSameMarker() {
  final String childMarkerName = CHILD_MAKER_NAME + "-ASM";
  final String parentMakerName = PARENT_MARKER_NAME + "-ASM";
  final org.slf4j.Marker slf4jMarker = org.slf4j.MarkerFactory.getMarker(childMarkerName);
  final org.slf4j.Marker slf4jParent = org.slf4j.MarkerFactory.getMarker(parentMakerName);
  slf4jMarker.add(slf4jParent);
  slf4jMarker.add(slf4jParent);
  final Marker log4jParent = MarkerManager.getMarker(parentMakerName);
  final Marker log4jMarker = MarkerManager.getMarker(childMarkerName);
  assertTrue(String.format("%s (log4jMarker=%s) is not an instance of %s (log4jParent=%s) in Log4j",
      childMarkerName, parentMakerName, log4jMarker, log4jParent), log4jMarker.isInstanceOf(log4jParent));
  assertTrue(String.format("%s (slf4jMarker=%s) is not an instance of %s (log4jParent=%s) in SLF4J",
      childMarkerName, parentMakerName, slf4jMarker, slf4jParent), slf4jMarker.contains(slf4jParent));
}

代码示例来源:origin: org.apache.logging.log4j/log4j-slf4j-impl

@Test
public void testAddMarker() {
  final String childMakerName = CHILD_MAKER_NAME + "-AM";
  final String parentMarkerName = PARENT_MARKER_NAME + "-AM";
  final org.slf4j.Marker slf4jMarker = org.slf4j.MarkerFactory.getMarker(childMakerName);
  final org.slf4j.Marker slf4jParent = org.slf4j.MarkerFactory.getMarker(parentMarkerName);
  slf4jMarker.add(slf4jParent);
  final Marker log4jParent = MarkerManager.getMarker(parentMarkerName);
  final Marker log4jMarker = MarkerManager.getMarker(childMakerName);
  assertTrue("Incorrect Marker class", slf4jMarker instanceof Log4jMarker);
  assertTrue(String.format("%s (log4jMarker=%s) is not an instance of %s (log4jParent=%s) in Log4j",
      childMakerName, parentMarkerName, log4jMarker, log4jParent), log4jMarker.isInstanceOf(log4jParent));
  assertTrue(String.format("%s (slf4jMarker=%s) is not an instance of %s (log4jParent=%s) in SLF4J",
      childMakerName, parentMarkerName, slf4jMarker, slf4jParent), slf4jMarker.contains(slf4jParent));
}

代码示例来源:origin: org.apache.logging.log4j/log4j-api

@Test
  public void testDuplicateParents() {
    final Marker parent = MarkerManager.getMarker("PARENT");
    final Marker existing = MarkerManager.getMarker("EXISTING");
    final Marker test1 = MarkerManager.getMarker("TEST1").setParents(existing);
    test1.addParents(parent);
    final Marker[] parents = test1.getParents();
    test1.addParents(existing);
    assertTrue("duplicate add allowed", parents.length == test1.getParents().length);
    test1.addParents(existing, MarkerManager.getMarker("EXTRA"));
    assertTrue("incorrect add", parents.length + 1 == test1.getParents().length);
    assertTrue("TEST1 is not an instance of PARENT", test1.isInstanceOf(parent));
    assertTrue("TEST1 is not an instance of EXISTING", test1.isInstanceOf(existing));
  }
}

代码示例来源:origin: org.apache.logging.log4j/log4j-slf4j18-impl

@Override
public boolean contains(final String s) {
  return s != null ? this.marker.isInstanceOf(s) : false;
}

代码示例来源:origin: ops4j/org.ops4j.pax.logging

private Result filter(final Marker marker) {
  return marker != null && marker.isInstanceOf(name) ? onMatch : onMismatch;
}

代码示例来源:origin: org.apache.logging.log4j/log4j-slf4j18-impl

@Override
public boolean contains(final Marker marker) {
  if (marker == null) {
    throw new IllegalArgumentException();
  }
  return this.marker.isInstanceOf(marker.getName());
}

代码示例来源:origin: ops4j/org.ops4j.pax.logging

@Override
public PatternFormatter[] getFormatters(final LogEvent event) {
  final Marker marker = event.getMarker();
  if (marker == null) {
    return defaultFormatters;
  }
  for (final String key : formatterMap.keySet()) {
    if (marker.isInstanceOf(key)) {
      return formatterMap.get(key);
    }
  }
  return defaultFormatters;
}

代码示例来源:origin: ops4j/org.ops4j.pax.logging

if (localParents != null) {
  for (final Marker parent : parentMarkers) {
    if (!(contains(parent, localParents) || parent.isInstanceOf(this))) {
      ++count;
  if (localParents == null || !(contains(parent, localParents) || parent.isInstanceOf(this))) {
    markers[index++] = parent;

相关文章