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


Java ThrowableProxy类代码示例

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


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

示例1: getFromThrowableProxy

import ch.qos.logback.classic.spi.ThrowableProxy; //导入依赖的package包/类
public static AbstractLoggingException getFromThrowableProxy(ThrowableProxy proxy) {
    if (proxy != null) {
        Throwable eventException = proxy.getThrowable();

        if (eventException instanceof AbstractLoggingException) {
            return (AbstractLoggingException) eventException;
        } else if (eventException.getCause() instanceof AbstractLoggingException) {
            // for spring boot projects there's a generic exception wrapper
            // let's try to cast the cause instead
            return (AbstractLoggingException) eventException.getCause();
        } else {
            triggerBadImplementationLog(eventException);

            return null;
        }
    }

    return null;
}
 
开发者ID:hmcts,项目名称:java-logging,代码行数:20,代码来源:AbstractLoggingException.java

示例2: appendStackTrace

import ch.qos.logback.classic.spi.ThrowableProxy; //导入依赖的package包/类
private void appendStackTrace(StringBuilder log, ThrowableProxy proxy) {
    if (proxy != null) {
        Stream<StackTraceElementProxy> trace = Arrays.stream(proxy.getStackTraceElementProxyArray());

        trace.forEach(step -> {
            String string = step.toString();

            log.append(CoreConstants.TAB).append(string);

            ThrowableProxyUtil.subjoinPackagingData(log, step);

            log.append(CoreConstants.LINE_SEPARATOR);
        });

        trace.close();
    }
}
 
开发者ID:hmcts,项目名称:java-logging,代码行数:18,代码来源:ReformLoggingLayout.java

示例3: loopCauses

import ch.qos.logback.classic.spi.ThrowableProxy; //导入依赖的package包/类
private void loopCauses(StringBuilder log, ThrowableProxy parentProxy, int depth) {
    ThrowableProxy cause = (ThrowableProxy) parentProxy.getCause();

    if (cause != null) {
        log.append(String.format(
            "Caused by: %s: %s",
            cause.getThrowable().getClass().getCanonicalName(),
            cause.getThrowable().getMessage()
        ));
        log.append(CoreConstants.LINE_SEPARATOR);
    }

    appendStackTrace(log, cause);

    if (cause != null && depth < STACKTRACE_DEPTH) {
        loopCauses(log, cause, depth + 1);
    }
}
 
开发者ID:hmcts,项目名称:java-logging,代码行数:19,代码来源:ReformLoggingLayout.java

示例4: decide

import ch.qos.logback.classic.spi.ThrowableProxy; //导入依赖的package包/类
@Override
public FilterReply decide(ILoggingEvent event) {
    if (event.getFormattedMessage().contains("Received 404 error, please notify the developer and include the URL ("))
        return FilterReply.DENY;
    if (event.getMarker() != Markers.NO_ANNOUNCE && Launcher.getInstance().getClient().isReady() && event.getLevel() == Level.ERROR) {
        String msg = event.getFormattedMessage();

        if (event.getThrowableProxy() != null && event.getThrowableProxy() instanceof ThrowableProxy) {
            @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
            Throwable throwable = ((ThrowableProxy) event.getThrowableProxy()).getThrowable();
            if (throwable != null) {
                msg += ' ';
                StringWriter sw = new StringWriter();
                PrintWriter pw = new PrintWriter(sw);
                throwable.printStackTrace(pw);
                msg += sw.toString();
                pw.close();
            }
        }
        Messages.send(msg, Launcher.getInstance().getClient().getChannelByID("233632081110892546"));
    }
    return FilterReply.NEUTRAL;
}
 
开发者ID:ArsenArsen,项目名称:ABot,代码行数:24,代码来源:ErrorInterceptor.java

示例5: decide

import ch.qos.logback.classic.spi.ThrowableProxy; //导入依赖的package包/类
@Override
public FilterReply decide(ILoggingEvent event) {
    String msg = event.getFormattedMessage();
    if (msg.startsWith("Received 40")) {
        return FilterReply.DENY;
    }
    if (msg.startsWith("Attempt to send message on closed")) {
        return FilterReply.DENY;
    }
    if (event.getMarker() != Markers.NO_ANNOUNCE
            && FlareBot.getInstance().getClient() != null
            && FlareBot.getInstance().getClient().isReady()
            && event.getLevel() == Level.ERROR) {
        EXECUTOR.submit(() -> {
            Throwable throwable = null;
            if (event.getThrowableProxy() != null && event.getThrowableProxy() instanceof ThrowableProxy) {
                throwable = ((ThrowableProxy) event.getThrowableProxy()).getThrowable();
            }
            if (throwable != null) {
                MessageUtils.sendException(msg, throwable, FlareBot.getInstance().getUpdateChannel());
            } else MessageUtils.sendMessage(msg, FlareBot.getInstance().getUpdateChannel());
        });
    }
    return FilterReply.NEUTRAL;
}
 
开发者ID:ArsenArsen,项目名称:FlareBot,代码行数:26,代码来源:ErrorCatcher.java

示例6: testAddException

import ch.qos.logback.classic.spi.ThrowableProxy; //导入依赖的package包/类
@Test
public void testAddException() throws Exception {
  //given
  final Exception throwable = new Exception("Some exception");
  final StringWriter stringWriter = new StringWriter();
  throwable.printStackTrace(new PrintWriter(stringWriter));
  ThrowableProxy throwableProxy = new ThrowableProxy(throwable);


  //when
  LogbackUtil.addException(throwableProxy,"Message!", builder);


  //then
  final LogData logData = builder.build();
  assertEquals(logData.getMessage(), "Message!\n" + stringWriter.getBuffer().toString());
}
 
开发者ID:otros-systems,项目名称:otroslogviewer,代码行数:18,代码来源:LogbackUtilTest.java

示例7: testEncodeArrayWithException

import ch.qos.logback.classic.spi.ThrowableProxy; //导入依赖的package包/类
@Test
public void testEncodeArrayWithException() throws Exception {
    final LoggingEvent event = new LoggingEvent();
    event.setLevel(Level.INFO);
    event.setMarker(StenoMarker.ARRAY_MARKER);
    event.setMessage("logEvent");
    event.setLoggerContextRemoteView(_context.getLoggerContextRemoteView());
    event.setTimeStamp(0);
    event.setThrowableProxy(new ThrowableProxy(new NullPointerException("npe!")));
    final Object[] argArray = new Object[2];
    argArray[0] = new String[]{};
    argArray[1] = new Object[]{};
    event.setArgumentArray(argArray);
    // CHECKSTYLE.OFF: IllegalInstantiation - This is valid case.
    final String logOutput = new String(_encoder.encode(event), _encoder.getCharset());
    // CHECKSTYLE.ON: IllegalInstantiation
    assertOutput("StenoEncoderTest.testEncodeArrayWithException.json", logOutput);
    assertMatchesJsonSchema(logOutput);
}
 
开发者ID:ArpNetworking,项目名称:logback-steno,代码行数:20,代码来源:StenoEncoderTest.java

示例8: testEncodeArrayWithCausedException

import ch.qos.logback.classic.spi.ThrowableProxy; //导入依赖的package包/类
@Test
public void testEncodeArrayWithCausedException() throws Exception {
    final LoggingEvent event = new LoggingEvent();
    event.setLevel(Level.INFO);
    event.setMarker(StenoMarker.ARRAY_MARKER);
    event.setMessage("logEvent");
    event.setLoggerContextRemoteView(_context.getLoggerContextRemoteView());
    event.setTimeStamp(0);
    event.setThrowableProxy(new ThrowableProxy(new UnsupportedOperationException("uoe!", new NullPointerException("npe!"))));
    final Object[] argArray = new Object[2];
    argArray[0] = new String[]{};
    argArray[1] = new Object[]{};
    event.setArgumentArray(argArray);
    // CHECKSTYLE.OFF: IllegalInstantiation - This is valid case.
    final String logOutput = new String(_encoder.encode(event), _encoder.getCharset());
    // CHECKSTYLE.ON: IllegalInstantiation
    assertOutput("StenoEncoderTest.testEncodeArrayWithCausedException.json", logOutput);
    assertMatchesJsonSchema(logOutput);
}
 
开发者ID:ArpNetworking,项目名称:logback-steno,代码行数:20,代码来源:StenoEncoderTest.java

示例9: testEncodeArrayWithSuppressedException

import ch.qos.logback.classic.spi.ThrowableProxy; //导入依赖的package包/类
@Test
public void testEncodeArrayWithSuppressedException() throws Exception {
    final LoggingEvent event = new LoggingEvent();
    event.setLevel(Level.INFO);
    event.setMarker(StenoMarker.ARRAY_MARKER);
    event.setMessage("logEvent");
    event.setLoggerContextRemoteView(_context.getLoggerContextRemoteView());
    event.setTimeStamp(0);
    final Throwable throwable = new NullPointerException("npe!");
    throwable.addSuppressed(new UnsupportedOperationException("uoe!"));
    event.setThrowableProxy(new ThrowableProxy(throwable));
    final Object[] argArray = new Object[2];
    argArray[0] = new String[]{};
    argArray[1] = new Object[]{};
    event.setArgumentArray(argArray);
    // CHECKSTYLE.OFF: IllegalInstantiation - This is valid case.
    // CHECKSTYLE.OFF: IllegalInstantiation - This is valid case.
    final String logOutput = new String(_encoder.encode(event), _encoder.getCharset());
    // CHECKSTYLE.ON: IllegalInstantiation
    // CHECKSTYLE.ON: IllegalInstantiation
    assertOutput("StenoEncoderTest.testEncodeArrayWithSuppressedException.json", logOutput);
    assertMatchesJsonSchema(logOutput);
}
 
开发者ID:ArpNetworking,项目名称:logback-steno,代码行数:24,代码来源:StenoEncoderTest.java

示例10: testEncodeArrayWithNullSuppressedException

import ch.qos.logback.classic.spi.ThrowableProxy; //导入依赖的package包/类
@Test
@SuppressFBWarnings(value = "SIC_INNER_SHOULD_BE_STATIC_ANON")
public void testEncodeArrayWithNullSuppressedException() throws Exception {
    final LoggingEvent event = new LoggingEvent();
    event.setLevel(Level.INFO);
    event.setMarker(StenoMarker.ARRAY_MARKER);
    event.setMessage("logEvent");
    event.setLoggerContextRemoteView(_context.getLoggerContextRemoteView());
    event.setTimeStamp(0);
    event.setThrowableProxy(new ThrowableProxy(new NullPointerException("npe!")) {
        @Override
        @SuppressFBWarnings(value = "PZLA_PREFER_ZERO_LENGTH_ARRAYS")
        public IThrowableProxy[] getSuppressed() {
            return null;
        }
    });
    final Object[] argArray = new Object[2];
    argArray[0] = new String[]{};
    argArray[1] = new Object[]{};
    event.setArgumentArray(argArray);
    // CHECKSTYLE.OFF: IllegalInstantiation - This is valid case.
    final String logOutput = new String(_encoder.encode(event), _encoder.getCharset());
    // CHECKSTYLE.ON: IllegalInstantiation
    assertOutput("StenoEncoderTest.testEncodeArrayWithNullSuppressedException.json", logOutput);
    assertMatchesJsonSchema(logOutput);
}
 
开发者ID:ArpNetworking,项目名称:logback-steno,代码行数:27,代码来源:StenoEncoderTest.java

示例11: append

import ch.qos.logback.classic.spi.ThrowableProxy; //导入依赖的package包/类
@Override
protected void append(ILoggingEvent event) {
    final IThrowableProxy throwableProxy = event.getThrowableProxy();
    final Map<String, String> mdc = event.getMDCPropertyMap();

    if ((throwableProxy != null) && (throwableProxy instanceof ThrowableProxy)) {
        ThrowableProxy proxy = (ThrowableProxy) throwableProxy;

        if (proxy.getThrowable() != null) {
            Map<String, String> params = new HashMap<>(mdc);

            if (!mdc.containsKey(MESSAGE_PARAM)) {
                params.put(MESSAGE_PARAM, event.getFormattedMessage());
            }

            noticeError(proxy.getThrowable(), params);

            return;
        }
    }

    noticeError(event.getFormattedMessage(), mdc);
}
 
开发者ID:abashev,项目名称:logback-newrelic-appender,代码行数:24,代码来源:NewRelicAppender.java

示例12: decide

import ch.qos.logback.classic.spi.ThrowableProxy; //导入依赖的package包/类
@Override
public FilterReply decide(ILoggingEvent event) {
	final IThrowableProxy throwableProxy = event.getThrowableProxy();
	if (throwableProxy == null) {
		return FilterReply.NEUTRAL;
	}

	if (!(throwableProxy instanceof ThrowableProxy)) {
		return FilterReply.NEUTRAL;
	}

	final ThrowableProxy throwableProxyImpl = (ThrowableProxy) throwableProxy;
	final Throwable throwable = throwableProxyImpl.getThrowable();
	if (java.nio.channels.ClosedChannelException.class.isInstance(throwable)) {
		return FilterReply.DENY;
	}

	return FilterReply.NEUTRAL;
}
 
开发者ID:NationStates,项目名称:NationStatesPlusPlus,代码行数:20,代码来源:LoggingFilter.java

示例13: makeEvent

import ch.qos.logback.classic.spi.ThrowableProxy; //导入依赖的package包/类
private LoggingEvent makeEvent(Level level, String message, Throwable th) {
	LoggingEvent event = new LoggingEvent();
	event.setLoggerName(CloudWatchAppender.class.getName());
	event.setLevel(level);
	event.setMessage(message);
	event.setTimeStamp(System.currentTimeMillis());
	if (th != null) {
		event.setThrowableProxy(new ThrowableProxy(th));
	}
	return event;
}
 
开发者ID:j256,项目名称:cloudwatch-logback-appender,代码行数:12,代码来源:CloudWatchAppender.java

示例14: matches

import ch.qos.logback.classic.spi.ThrowableProxy; //导入依赖的package包/类
@Override
public boolean matches(Object item) {
  if (item instanceof ThrowableProxy) {
    return expectedException.matches(((ThrowableProxy) item).getThrowable());
  }

  return false;
}
 
开发者ID:mustaine,项目名称:logcapture,代码行数:9,代码来源:ExpectedExceptionMatcher.java

示例15: match_when_ThrowableProxy_contains_exception

import ch.qos.logback.classic.spi.ThrowableProxy; //导入依赖的package包/类
@Test
public void match_when_ThrowableProxy_contains_exception() {
  ExpectedExceptionMatcher expectedExceptionMatcher = new ExpectedExceptionMatcher(isA(RuntimeException.class));

  boolean matches = expectedExceptionMatcher.matches(new ThrowableProxy(new RuntimeException()));

  assertThat(matches).isTrue();
}
 
开发者ID:mustaine,项目名称:logcapture,代码行数:9,代码来源:ExpectedExceptionMatcherShould.java


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