当前位置: 首页>>代码示例>>Java>>正文


Java Marker类代码示例

本文整理汇总了Java中org.apache.logging.log4j.Marker的典型用法代码示例。如果您正苦于以下问题:Java Marker类的具体用法?Java Marker怎么用?Java Marker使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Marker类属于org.apache.logging.log4j包,在下文中一共展示了Marker类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: PrefixLogger

import org.apache.logging.log4j.Marker; //导入依赖的package包/类
PrefixLogger(final ExtendedLogger logger, final String name, final String prefix) {
    super(logger, name, null);

    final String actualPrefix = (prefix == null ? "" : prefix).intern();
    final Marker actualMarker;
    // markers is not thread-safe, so we synchronize access
    synchronized (markers) {
        final WeakReference<Marker> marker = markers.get(actualPrefix);
        final Marker maybeMarker = marker == null ? null : marker.get();
        if (maybeMarker == null) {
            actualMarker = new MarkerManager.Log4jMarker(actualPrefix);
            markers.put(actualPrefix, new WeakReference<>(actualMarker));
        } else {
            actualMarker = maybeMarker;
        }
    }
    this.marker = actualMarker;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:PrefixLogger.java

示例2: notDelegateIsTraceEnabledWhenNotIsDelegating

import org.apache.logging.log4j.Marker; //导入依赖的package包/类
/**
 * FastLogger should not delegate isTraceEnabled when not isDelegating
 */
@Test
public void notDelegateIsTraceEnabledWhenNotIsDelegating() {
  FastLogger.setDelegating(false);
  when(mockedLogger.getLevel()).thenReturn(Level.INFO);

  FastLogger fastLogger = new FastLogger(this.mockedLogger);

  assertThat(fastLogger.getLevel(), is(Level.INFO));
  assertThat(fastLogger.isTraceEnabled(), is(false));
  assertThat(fastLogger.isTraceEnabled(this.mockedMarker), is(false));
  verify(this.mockedLogger, times(0)).isEnabled(eq(Level.TRACE), isNull(Marker.class),
      isNull(String.class));
  verify(this.mockedLogger, times(0)).isEnabled(eq(Level.TRACE), eq(this.mockedMarker),
      isNull(Object.class), isNull(Throwable.class));
}
 
开发者ID:ampool,项目名称:monarch,代码行数:19,代码来源:FastLoggerJUnitTest.java

示例3: delegateIsTraceEnabledWhenIsDelegating

import org.apache.logging.log4j.Marker; //导入依赖的package包/类
/**
 * FastLogger should delegate isTraceEnabled when isDelegating
 */
@Test
public void delegateIsTraceEnabledWhenIsDelegating() {
  FastLogger.setDelegating(true);
  when(this.mockedLogger.getLevel()).thenReturn(Level.TRACE);
  when(this.mockedLogger.isEnabled(eq(Level.TRACE), isNull(Marker.class), isNull(Object.class),
      isNull(Throwable.class))).thenReturn(true);
  when(this.mockedLogger.isEnabled(eq(Level.TRACE), eq(this.mockedMarker), isNull(Object.class),
      isNull(Throwable.class))).thenReturn(true);

  FastLogger fastLogger = new FastLogger(this.mockedLogger);

  assertThat(fastLogger.isTraceEnabled(), is(true));
  assertThat(fastLogger.isTraceEnabled(this.mockedMarker), is(true));
  verify(this.mockedLogger, times(1)).isEnabled(eq(Level.TRACE), isNull(Marker.class),
      isNull(Object.class), isNull(Throwable.class));
  verify(this.mockedLogger, times(1)).isEnabled(eq(Level.TRACE), eq(this.mockedMarker),
      isNull(Object.class), isNull(Throwable.class));
}
 
开发者ID:ampool,项目名称:monarch,代码行数:22,代码来源:FastLoggerJUnitTest.java

示例4: notDelegateIsDebugEnabledWhenNotIsDelegating

import org.apache.logging.log4j.Marker; //导入依赖的package包/类
/**
 * FastLogger should not delegate isDebugEnabled when not isDelegating
 */
@Test
public void notDelegateIsDebugEnabledWhenNotIsDelegating() {
  FastLogger.setDelegating(false);
  when(this.mockedLogger.getLevel()).thenReturn(Level.INFO);

  FastLogger fastLogger = new FastLogger(this.mockedLogger);

  assertThat(fastLogger.getLevel(), is(Level.INFO));
  assertThat(fastLogger.isDebugEnabled(), is(false));
  assertThat(fastLogger.isDebugEnabled(this.mockedMarker), is(false));
  verify(this.mockedLogger, times(0)).isEnabled(eq(Level.DEBUG), isNull(Marker.class),
      isNull(String.class));
  verify(this.mockedLogger, times(0)).isEnabled(eq(Level.DEBUG), eq(this.mockedMarker),
      isNull(Object.class), isNull(Throwable.class));
}
 
开发者ID:ampool,项目名称:monarch,代码行数:19,代码来源:FastLoggerJUnitTest.java

示例5: setUp

import org.apache.logging.log4j.Marker; //导入依赖的package包/类
@Before
public void setUp() {
  this.messageFactory = new ParameterizedMessageFactory();
  this.mockedLogger = mock(ExtendedLogger.class);
  this.mockedMarker = mock(Marker.class);

  when(this.mockedLogger.getMessageFactory()).thenReturn(this.messageFactory);
  when(this.mockedMarker.getName()).thenReturn("MARKER");
}
 
开发者ID:ampool,项目名称:monarch,代码行数:10,代码来源:FastLoggerJUnitTest.java

示例6: testLoggerUsageCheckerCompatibilityWithLog4j2Logger

import org.apache.logging.log4j.Marker; //导入依赖的package包/类
public void testLoggerUsageCheckerCompatibilityWithLog4j2Logger() throws NoSuchMethodException {
    for (Method method : Logger.class.getMethods()) {
        if (ESLoggerUsageChecker.LOGGER_METHODS.contains(method.getName())) {
            assertThat(method.getParameterTypes().length, greaterThanOrEqualTo(1));
            int markerOffset = method.getParameterTypes()[0].equals(Marker.class) ? 1 : 0;
            int paramLength = method.getParameterTypes().length - markerOffset;
            if (method.isVarArgs()) {
                assertEquals(2, paramLength);
                assertEquals(String.class, method.getParameterTypes()[markerOffset]);
                assertThat(method.getParameterTypes()[markerOffset + 1], Matchers.<Class<?>>isOneOf(Object[].class, Supplier[].class));
            } else {
                assertThat(method.getParameterTypes()[markerOffset], Matchers.<Class<?>>isOneOf(Message.class, MessageSupplier.class,
                    CharSequence.class, Object.class, String.class, Supplier.class));

                if (paramLength == 2) {
                    assertThat(method.getParameterTypes()[markerOffset + 1], Matchers.<Class<?>>isOneOf(Throwable.class, Object.class));
                    if (method.getParameterTypes()[markerOffset + 1].equals(Object.class)) {
                        assertEquals(String.class, method.getParameterTypes()[markerOffset]);
                    }
                }
                if (paramLength > 2) {
                    assertEquals(String.class, method.getParameterTypes()[markerOffset]);
                    assertThat(paramLength, lessThanOrEqualTo(11));
                    for (int i = 1; i < paramLength; i++) {
                        assertEquals(Object.class, method.getParameterTypes()[markerOffset + i]);
                    }
                }
            }
        }
    }

    for (String methodName : ESLoggerUsageChecker.LOGGER_METHODS) {
        assertEquals(48, Stream.of(Logger.class.getMethods()).filter(m -> methodName.equals(m.getName())).count());
    }

    for (Constructor<?> constructor : ParameterizedMessage.class.getConstructors()) {
        assertThat(constructor.getParameterTypes().length, greaterThanOrEqualTo(2));
        assertEquals(String.class, constructor.getParameterTypes()[0]);
        assertThat(constructor.getParameterTypes()[1], Matchers.<Class<?>>isOneOf(String[].class, Object[].class, Object.class));

        if (constructor.getParameterTypes().length > 2) {
            assertEquals(3, constructor.getParameterTypes().length);
            if (constructor.getParameterTypes()[1].equals(Object.class)) {
                assertEquals(Object.class, constructor.getParameterTypes()[2]);
            } else {
                assertEquals(Throwable.class, constructor.getParameterTypes()[2]);
            }
        }
    }

    assertEquals(5, ParameterizedMessage.class.getConstructors().length);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:53,代码来源:ESLoggerUsageTests.java

示例7: createLogEvent

import org.apache.logging.log4j.Marker; //导入依赖的package包/类
/**
 * @return a log event that uses all the bells and whistles, features, nooks and crannies
 */
static Log4jLogEvent createLogEvent() {
    final Marker cMarker = MarkerManager.getMarker("Marker1");
    final Marker pMarker1 = MarkerManager.getMarker("ParentMarker1");
    final Marker pMarker2 = MarkerManager.getMarker("ParentMarker2");
    final Marker gfMarker = MarkerManager.getMarker("GrandFatherMarker");
    final Marker gmMarker = MarkerManager.getMarker("GrandMotherMarker");
    cMarker.addParents(pMarker1);
    cMarker.addParents(pMarker2);
    pMarker1.addParents(gmMarker);
    pMarker1.addParents(gfMarker);
    final Exception sourceHelper = new Exception();
    sourceHelper.fillInStackTrace();
    final Exception cause = new NullPointerException("testNPEx");
    sourceHelper.fillInStackTrace();
    final StackTraceElement source = sourceHelper.getStackTrace()[0];
    final IOException ioException = new IOException("testIOEx", cause);
    ioException.addSuppressed(new IndexOutOfBoundsException("I am suppressed exception 1"));
    ioException.addSuppressed(new IndexOutOfBoundsException("I am suppressed exception 2"));
    final ThrowableProxy throwableProxy = new ThrowableProxy(ioException);
    final Map<String, String> contextMap = new HashMap<>();
    contextMap.put("MDC.A", "A_Value");
    contextMap.put("MDC.B", "B_Value");
    final DefaultThreadContextStack contextStack = new DefaultThreadContextStack(true);
    contextStack.clear();
    contextStack.push("stack_msg1");
    contextStack.add("stack_msg2");
    final Log4jLogEvent expected = Log4jLogEvent.newBuilder() //
            .setLoggerName("a.B") //
            .setMarker(cMarker) //
            .setLoggerFqcn("f.q.c.n") //
            .setLevel(Level.DEBUG) //
            .setMessage(new SimpleMessage("Msg")) //
            .setThrown(ioException) //
            .setThrownProxy(throwableProxy) //
            .setContextMap(contextMap) //
            .setContextStack(contextStack) //
            .setThreadName("MyThreadName") //
            .setSource(source) //
            .setTimeMillis(1).build();
    // validate event?
    return expected;
}
 
开发者ID:savantly-net,项目名称:log4j2-extended-jsonlayout,代码行数:46,代码来源:LogEventFixtures.java

示例8: isDebugEnabled

import org.apache.logging.log4j.Marker; //导入依赖的package包/类
@Override
public boolean isDebugEnabled(final Marker marker) {
  return delegating && super.isDebugEnabled(marker);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:5,代码来源:FastLogger.java

示例9: isTraceEnabled

import org.apache.logging.log4j.Marker; //导入依赖的package包/类
@Override
public boolean isTraceEnabled(final Marker marker) {
  return delegating && super.isTraceEnabled(marker);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:5,代码来源:FastLogger.java

示例10: warn

import org.apache.logging.log4j.Marker; //导入依赖的package包/类
/** Logs warning messages. */
public static void warn(Marker marker, String msg) {
    logger.warn(marker, msg);
}
 
开发者ID:tbressler,项目名称:waterrower-workout,代码行数:5,代码来源:Log.java

示例11: debug

import org.apache.logging.log4j.Marker; //导入依赖的package包/类
/** Logs debug messages. */
public static void debug(Marker marker, String msg) {
    logger.debug(marker, msg);
}
 
开发者ID:tbressler,项目名称:waterrower-core,代码行数:5,代码来源:Log.java

示例12: filter

import org.apache.logging.log4j.Marker; //导入依赖的package包/类
/**
 * Ignore.
 *
 * @return result
 */
@Override
public Result filter(Logger logger, Level level, Marker marker, String s, Object... objects) {
    return null;
}
 
开发者ID:Shynixn,项目名称:PetBlocks,代码行数:10,代码来源:PetBlockFilter.java

示例13: finest

import org.apache.logging.log4j.Marker; //导入依赖的package包/类
/**
 * Logs a message with the specific Marker at the {@code Level.TRACE} level.
 * 
 * @param marker the marker data specific to this log statement
 * @param msg the message string to be logged
 */
public void finest(final Marker marker, final Message msg) {
  this.logWrapper.logIfEnabled(this.loggerName, Level.TRACE, marker, msg, (Throwable) null);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:10,代码来源:LogWriterLogger.java

示例14: severe

import org.apache.logging.log4j.Marker; //导入依赖的package包/类
/**
 * Logs a message with the specific Marker at the;@code SEVERE} level.
 * 
 * @param marker the marker data specific to this log statement
 * @param msg the message string to be logged
 */
public void severe(final Marker marker, final Message msg);
 
开发者ID:ampool,项目名称:monarch,代码行数:8,代码来源:GemFireLogger.java

示例15: finer

import org.apache.logging.log4j.Marker; //导入依赖的package包/类
/**
 * Logs a message with the specific Marker at the {@code Level.TRACE} level.
 * 
 * @param marker the marker data specific to this log statement
 * @param msg the message string to be logged
 */
public void finer(final Marker marker, final Message msg) {
  this.logWrapper.logIfEnabled(this.loggerName, Level.TRACE, marker, msg, (Throwable) null);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:10,代码来源:LogWriterLogger.java


注:本文中的org.apache.logging.log4j.Marker类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。