本文整理汇总了Java中ch.qos.logback.classic.spi.IThrowableProxy.getSuppressed方法的典型用法代码示例。如果您正苦于以下问题:Java IThrowableProxy.getSuppressed方法的具体用法?Java IThrowableProxy.getSuppressed怎么用?Java IThrowableProxy.getSuppressed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ch.qos.logback.classic.spi.IThrowableProxy
的用法示例。
在下文中一共展示了IThrowableProxy.getSuppressed方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: appendThrowable
import ch.qos.logback.classic.spi.IThrowableProxy; //导入方法依赖的package包/类
private void appendThrowable(IThrowableProxy proxy, ILoggingEvent loggingEvent) {
//Append Exception Message
appendToLog(loggingEvent, String.format("%s: %s", proxy.getClassName(), proxy.getMessage()));
//Append Exception Stack Trace
for (StackTraceElementProxy element : loggingEvent.getThrowableProxy().getStackTraceElementProxyArray()) {
appendToLog(loggingEvent, "\t" + element.getSTEAsString());
}
if (proxy.getSuppressed().length > 0) {
appendToLog(loggingEvent, "Suppressed Exceptions:");
for (IThrowableProxy p : proxy.getSuppressed()) {
appendThrowable(p, loggingEvent);
}
}
if (proxy.getCause() != null) {
appendToLog(loggingEvent, "Cause:");
appendThrowable(proxy.getCause(), loggingEvent);
}
}
示例2: recursiveAppendRootCauseFirst
import ch.qos.logback.classic.spi.IThrowableProxy; //导入方法依赖的package包/类
protected void recursiveAppendRootCauseFirst(StringBuilder sb, String prefix, int indent, IThrowableProxy tp) {
if (tp.getCause() != null) {
recursiveAppendRootCauseFirst(sb, prefix, indent, tp.getCause());
prefix = null; // to avoid adding it more than once
}
ThrowableProxyUtil.indent(sb, indent - 1);
if (prefix != null) {
sb.append(prefix);
}
ThrowableProxyUtil.subjoinFirstLineRootCauseFirst(sb, tp);
sb.append(CoreConstants.LINE_SEPARATOR);
subjoinSTEPArray(sb, indent, tp);
IThrowableProxy[] suppressed = tp.getSuppressed();
if(suppressed != null) {
for(IThrowableProxy current : suppressed) {
recursiveAppendRootCauseFirst(sb, CoreConstants.SUPPRESSED, indent + ThrowableProxyUtil.SUPPRESSED_EXCEPTION_INDENT, current);
}
}
}
示例3: toProto
import ch.qos.logback.classic.spi.IThrowableProxy; //导入方法依赖的package包/类
private static Proto.Throwable toProto(IThrowableProxy t) {
Proto.Throwable.Builder builder = Proto.Throwable.newBuilder()
.setClassName(t.getClassName());
String message = t.getMessage();
if (message != null) {
builder.setMessage(message);
}
for (StackTraceElementProxy element : t.getStackTraceElementProxyArray()) {
builder.addStackTraceElement(ErrorMessage.toProto(element.getStackTraceElement()));
}
builder.setFramesInCommonWithEnclosing(t.getCommonFrames());
IThrowableProxy cause = t.getCause();
if (cause != null) {
builder.setCause(toProto(cause));
}
for (IThrowableProxy suppressed : t.getSuppressed()) {
builder.addSuppressed(toProto(suppressed));
}
return builder.build();
}
示例4: recursiveAppend
import ch.qos.logback.classic.spi.IThrowableProxy; //导入方法依赖的package包/类
private void recursiveAppend(StringBuilder sb, String prefix, int indent, IThrowableProxy tp) {
if(tp == null)
return;
subjoinFirstLine(sb, prefix, indent, tp);
sb.append(CoreConstants.LINE_SEPARATOR);
subjoinSTEPArray(sb, indent, tp);
IThrowableProxy[] suppressed = tp.getSuppressed();
if(suppressed != null) {
for(IThrowableProxy current : suppressed) {
recursiveAppend(sb, CoreConstants.SUPPRESSED, indent + ThrowableProxyUtil.SUPPRESSED_EXCEPTION_INDENT, current);
}
}
recursiveAppend(sb, CoreConstants.CAUSED_BY, indent, tp.getCause());
}
示例5: serializeThrowable
import ch.qos.logback.classic.spi.IThrowableProxy; //导入方法依赖的package包/类
/**
* This function assumes the field object has already been started for this throwable, this only fills in
* the fields in the 'exception' or equivalent object and does not create the field in the containing object.
*
* @since 1.7.0
* @param throwableProxy Throwable to serialize
* @param jsonGenerator <code>JsonGenerator</code> instance after exception object is started
* @param objectMapper <code>ObjectMapper</code> instance.
* @throws IOException If writing the <code>Throwable</code> as JSON fails.
*/
public static void serializeThrowable(
final IThrowableProxy throwableProxy,
final JsonGenerator jsonGenerator,
final ObjectMapper objectMapper)
throws IOException {
jsonGenerator.writeStringField("type", throwableProxy.getClassName());
jsonGenerator.writeStringField("message", throwableProxy.getMessage());
jsonGenerator.writeArrayFieldStart("backtrace");
for (final StackTraceElementProxy ste : throwableProxy.getStackTraceElementProxyArray()) {
jsonGenerator.writeString(ste.toString());
}
jsonGenerator.writeEndArray();
jsonGenerator.writeObjectFieldStart("data");
if (throwableProxy instanceof ThrowableProxy) {
final JsonNode jsonNode = objectMapper.valueToTree(((ThrowableProxy) throwableProxy).getThrowable());
for (final Iterator<Map.Entry<String, JsonNode>> iterator = jsonNode.fields(); iterator.hasNext();) {
final Map.Entry<String, JsonNode> field = iterator.next();
jsonGenerator.writeFieldName(field.getKey());
objectMapper.writeValue(
jsonGenerator,
field.getValue());
}
}
// Although Throwable has a final getSuppressed which cannot return a null array, the
// proxy in Logback provides no such guarantees.
if (throwableProxy.getSuppressed() != null && throwableProxy.getSuppressed().length > 0) {
jsonGenerator.writeArrayFieldStart("suppressed");
for (final IThrowableProxy suppressed : throwableProxy.getSuppressed()) {
jsonGenerator.writeStartObject();
serializeThrowable(suppressed, jsonGenerator, objectMapper);
jsonGenerator.writeEndObject();
}
jsonGenerator.writeEndArray();
}
if (throwableProxy.getCause() != null) {
jsonGenerator.writeObjectFieldStart("cause");
serializeThrowable(throwableProxy.getCause(), jsonGenerator, objectMapper);
jsonGenerator.writeEndObject();
}
jsonGenerator.writeEndObject();
}