• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ThrowableProxy类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: not_match_when_ThrowableProxy_contains_another_exception

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

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

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


示例17: writeTo

import ch.qos.logback.classic.spi.ThrowableProxy; //导入依赖的package包/类
@Override
public void writeTo(JsonGenerator generator, ILoggingEvent event) throws IOException {
    if (require) {
        ThrowableProxy proxy = (ThrowableProxy) event.getThrowableProxy();
        AbstractLoggingException exception = AbstractLoggingException.getFromThrowableProxy(proxy);

        if (exception != null) {
            JsonWritingUtils.writeStringField(generator, getFieldName(), getValue(exception));
        }
    }
}
 
开发者ID:hmcts,项目名称:java-logging,代码行数:12,代码来源:AbstractRequireJsonProvider.java


示例18: doLayout

import ch.qos.logback.classic.spi.ThrowableProxy; //导入依赖的package包/类
@Override
public String doLayout(ILoggingEvent event) {
    Instant instant = Instant.ofEpochMilli(event.getTimeStamp());
    ZonedDateTime dateTime = ZonedDateTime.ofInstant(instant, ZoneId.systemDefault());
    StringBuilder log = new StringBuilder(dateTime.format(dateFormat));

    log.append(String.format(" %-5s", event.getLevel().levelStr));

    if (requireThread) {
        log.append(String.format(" [%s]", event.getThreadName()));
    }

    int lineNumber = event.getCallerData().length > 0 ? event.getCallerData()[0].getLineNumber() : 0;

    log.append(String.format(" %s:%d: ", event.getLoggerName(), lineNumber));

    ThrowableProxy proxy = (ThrowableProxy) event.getThrowableProxy();

    if (requireAlertLevel || requireErrorCode) {
        appendExtraExceptionFlags(log, AbstractLoggingException.getFromThrowableProxy(proxy));
    }

    log.append(event.getFormattedMessage()).append(CoreConstants.LINE_SEPARATOR);

    appendStackTrace(log, proxy);

    if (proxy != null) {
        loopCauses(log, proxy, 0);
    }

    return log.toString();
}
 
开发者ID:hmcts,项目名称:java-logging,代码行数:33,代码来源:ReformLoggingLayout.java


示例19: onLog

import ch.qos.logback.classic.spi.ThrowableProxy; //导入依赖的package包/类
@Override
public void onLog(LogEntry logEntry) {

  final LoggingEvent loggingEvent = new LoggingEvent();
  loggingEvent.setTimeStamp(logEntry.getTimestamp());
  loggingEvent.setLoggerName(logEntry.getLoggerName());
  loggingEvent.setLevel(Level.valueOf(logEntry.getLogLevel().name()));
  loggingEvent.setThreadName(logEntry.getThreadName());
  Object [] formatObjects = new Object[] {logEntry.getHost(),
    getSimpleClassName(logEntry.getSourceClassName()),
    logEntry.getSourceMethodName(),
    logEntry.getFileName(),
    logEntry.getLineNumber(),logEntry.getMessage()};
  loggingEvent.setMessage(MESSAGE_FORMAT.get().format(formatObjects));

  // Prints the throwable and stack trace.
  LogThrowable logThrowable = logEntry.getThrowable();
  if (logThrowable != null) {
    loggingEvent.setThrowableProxy(new ThrowableProxy(setThrowable(logThrowable)));
  }

  if (logger instanceof Logger) {
    ((Logger) logger).callAppenders(loggingEvent);
  } else {
    logger.info("Logger is not instance of ch.qos.logback.classic.Logger. Logger event is: {}", loggingEvent);
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:28,代码来源:YarnTwillLogHandler.java


示例20: withStackTrace

import ch.qos.logback.classic.spi.ThrowableProxy; //导入依赖的package包/类
@Test
public void withStackTrace() throws Exception {
    event.setThrowableProxy(new ThrowableProxy(new RuntimeException()));
    String s = converter.convert(event);
    System.out.println(s);
    assertThat(s, startsWith("java.lang.RuntimeException: null\\n    at com."));
}
 
开发者ID:roundrop,项目名称:logback-oneline-converter,代码行数:8,代码来源:OnelineExtendedThrowableProxyConverterTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DefaultViewerCreator类代码示例发布时间:2022-05-21
下一篇:
Java SimpleStringFilter类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap