當前位置: 首頁>>代碼示例>>Java>>正文


Java IThrowableProxy類代碼示例

本文整理匯總了Java中ch.qos.logback.classic.spi.IThrowableProxy的典型用法代碼示例。如果您正苦於以下問題:Java IThrowableProxy類的具體用法?Java IThrowableProxy怎麽用?Java IThrowableProxy使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


IThrowableProxy類屬於ch.qos.logback.classic.spi包,在下文中一共展示了IThrowableProxy類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: fullDump

import ch.qos.logback.classic.spi.IThrowableProxy; //導入依賴的package包/類
public String fullDump(ILoggingEvent evt) {
	try {
		IThrowableProxy proxy = evt.getThrowableProxy();
		if(proxy == null)
			return null;
		
		StringBuilder builder = new StringBuilder();
		for (StackTraceElementProxy step : proxy
				.getStackTraceElementProxyArray()) {
			String string = step.toString();
			builder.append(CoreConstants.TAB).append(string);
			ThrowableProxyUtil.subjoinPackagingData(builder, step);
			builder.append(CoreConstants.LINE_SEPARATOR);
		}
		return builder.toString();
	} catch(Exception e) {
		addError("exception trying to log exception", e);
		return "exception parsing exception";
	}
}
 
開發者ID:guci314,項目名稱:playorm,代碼行數:21,代碼來源:CassandraAppender.java

示例2: 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);
    }
}
 
開發者ID:StuPro-TOSCAna,項目名稱:TOSCAna,代碼行數:19,代碼來源:MemoryAppender.java

示例3: render

import ch.qos.logback.classic.spi.IThrowableProxy; //導入依賴的package包/類
void render(StringBuilder sbuf, IThrowableProxy tp) {
    printFirstLine(sbuf, tp);

    int commonFrames = tp.getCommonFrames();
    StackTraceElementProxy[] stepArray = tp.getStackTraceElementProxyArray();

    for (int i = 0; i < stepArray.length - commonFrames; i++) {
        StackTraceElementProxy step = stepArray[i];
        sbuf.append(TRACE_PREFIX);
        sbuf.append(Transform.escapeTags(step.toString()));
        sbuf.append(CoreConstants.LINE_SEPARATOR);
    }

    if (commonFrames > 0) {
        sbuf.append(TRACE_PREFIX);
        sbuf.append("\t... ").append(commonFrames).append(" common frames omitted").append(CoreConstants.LINE_SEPARATOR);
    }
}
 
開發者ID:zhaoqilong3031,項目名稱:spring-cloud-samples,代碼行數:19,代碼來源:DefaultThrowableRenderer.java

示例4: transformStackTrace

import ch.qos.logback.classic.spi.IThrowableProxy; //導入依賴的package包/類
private String transformStackTrace(ILoggingEvent event) {
    IThrowableProxy throwableProxy = event.getThrowableProxy();
    StackTraceElement stackTraceElement = throwableProxy.getStackTraceElementProxyArray()[0].getStackTraceElement();

    String time = DEFAULT_DATE_FORMAT.format(new Date(event.getTimeStamp()));
    String threadName = event.getThreadName();
    String level = event.getLevel().toString().substring(0, 1);
    String logger = event.getLoggerName();
    String exception = throwableProxy.getClassName();
    String msg = throwableProxy.getMessage();
    String className = stackTraceElement.getClassName();
    String method = stackTraceElement.getMethodName();
    int lineNumber = stackTraceElement.getLineNumber();

    return String.format(FORMAT_MESSAGE, title, time, threadName, level, logger, exception, msg, className, method, lineNumber);
}
 
開發者ID:mitaketw,項目名稱:logback-sms-appender,代碼行數:17,代碼來源:SmsAppender.java

示例5: append

import ch.qos.logback.classic.spi.IThrowableProxy; //導入依賴的package包/類
@Override
protected void append(ILoggingEvent event) {
    if (event == null) {
        return;
    }
    if (event.getLevel() == Level.ERROR || event.getLevel() == Level.WARN) {
        IThrowableProxy throwableProxy = event.getThrowableProxy();
        if (throwableProxy != null) {
        	//接口名
            String errorClassName = throwableProxy.getClassName();
            if (errorClassName != null && !"".equals(errorClassName.trim())) {
            	//寫入AtomicLongMap並計數
                ERROR_NAME_VALUE_MAP.getAndIncrement(errorClassName);
            }
        }
    }
}
 
開發者ID:sohutv,項目名稱:cachecloud,代碼行數:18,代碼來源:ErrorStatisticsAppender.java

示例6: 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);
    }
  }
}
 
開發者ID:cscfa,項目名稱:bartleby,代碼行數:20,代碼來源:RootCauseFirstThrowableProxyConverter.java

示例7: render

import ch.qos.logback.classic.spi.IThrowableProxy; //導入依賴的package包/類
void render(StringBuilder sbuf, IThrowableProxy tp) {
  printFirstLine(sbuf, tp);
  
  int commonFrames = tp.getCommonFrames();
  StackTraceElementProxy[] stepArray = tp.getStackTraceElementProxyArray();
  
  for (int i = 0; i < stepArray.length - commonFrames; i++) {
    StackTraceElementProxy step = stepArray[i];
    sbuf.append(TRACE_PREFIX);
    sbuf.append(Transform.escapeTags(step.toString()));
    sbuf.append(CoreConstants.LINE_SEPARATOR);
  }
  
  if (commonFrames > 0) {
    sbuf.append(TRACE_PREFIX);
    sbuf.append("\t... ").append(commonFrames).append(" common frames omitted")
        .append(CoreConstants.LINE_SEPARATOR);
  }
}
 
開發者ID:cscfa,項目名稱:bartleby,代碼行數:20,代碼來源:DefaultThrowableRenderer.java

示例8: subjoinThrowableProxy

import ch.qos.logback.classic.spi.IThrowableProxy; //導入依賴的package包/類
void subjoinThrowableProxy(StringBuilder buf, IThrowableProxy tp) {
    subjoinFirstLine(buf, tp);


    buf.append(CoreConstants.LINE_SEPARATOR);
    final StackTraceElementProxy[] stepArray = tp.getStackTraceElementProxyArray();
    final int commonFrames = tp.getCommonFrames();

    int maxIndex = stepArray.length;
    if (commonFrames > 0) {
        maxIndex -= commonFrames;
    }

    for (int i = 0; i < maxIndex; i++) {
        final String string = stepArray[i].toString();
        buf.append(PREFIX);
        buf.append(string);
        extraData(buf, stepArray[i]); // allow other data to be added
        buf.append(CoreConstants.LINE_SEPARATOR);
    }

    if (commonFrames > 0) {
        buf.append("!... ").append(tp.getCommonFrames()).append(
                " common frames omitted").append(CoreConstants.LINE_SEPARATOR);
    }
}
 
開發者ID:bither,項目名稱:bither-desktop-java,代碼行數:27,代碼來源:PrefixedThrowableProxyConverter.java

示例9: convertToStackTraces

import ch.qos.logback.classic.spi.IThrowableProxy; //導入依賴的package包/類
private List<StackTraceVO> convertToStackTraces(final IThrowableProxy throwableProxy) {
    final StackTraceElementProxy[] stackTraceElementProxies = throwableProxy.getStackTraceElementProxyArray();
    final List<StackTraceVO> stackTraces = Lists.newArrayList();

    for (final StackTraceElementProxy stackTraceElementProxy : stackTraceElementProxies) {
        final StackTraceElement stackTraceElement = stackTraceElementProxy.getStackTraceElement();

        final StackTraceVO stackTrace = new StackTraceVO();
        stackTrace.setMethod(stackTraceElement.getClassName() + "." + stackTraceElement.getMethodName());
        stackTrace.setLineNumber(stackTraceElement.getLineNumber());
        stackTrace.setFile(stackTraceElement.getFileName());
        stackTrace.setInProject(configuration.isInProject(stackTraceElement.getClassName()));

        stackTraces.add(stackTrace);
    }

    return stackTraces;
}
 
開發者ID:codereligion,項目名稱:bugsnag-logback,代碼行數:19,代碼來源:Converter.java

示例10: buildCausalString

import ch.qos.logback.classic.spi.IThrowableProxy; //導入依賴的package包/類
/**
 * Builds an exception causation string by following the exception caused-by chain.
 * @param exception The exception to process.
 * @return A string describing all exceptions in the chain.
 */
private static String buildCausalString(IThrowableProxy exception)
{
  final StringBuilder buff = new StringBuilder();

  buff.append(exception.getClassName());
  if (exception.getMessage() != null)
  {
    buff.append(": ").append(exception.getMessage());
  }

  if (exception.getCause() != null)
  {
    buff.append("; caused by: ").append(buildCausalString(exception.getCause()));
  }

  return buff.toString();
}
 
開發者ID:gkopff,項目名稱:logback-raygun,代碼行數:23,代碼來源:RaygunAppender.java

示例11: createThrowableData

import ch.qos.logback.classic.spi.IThrowableProxy; //導入依賴的package包/類
/**
 * fluentdサーバに転送するログデータに格納する例外情報を生成する。
 * 
 * @param th 例外データ。
 * @return 例外情報。
 */
private Map<String, Object> createThrowableData(IThrowableProxy th) {

	Map<String, Object> data = new LinkedHashMap<>();
	data.put("className", th.getClassName());
	data.put("message", th.getMessage());

	List<String> stackTrace = new ArrayList<>();
	for (StackTraceElementProxy ste : th.getStackTraceElementProxyArray()) {
		stackTrace.add(ste.toString());
	}
	data.put("stackTrace", stackTrace);

	if (th.getCause() != null) {
		data.put("cause", createThrowableData(th.getCause()));
	}

	return data;
}
 
開發者ID:agwlvssainokuni,項目名稱:sqlapp,代碼行數:25,代碼來源:FluentLoggerAppender.java

示例12: 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();
}
 
開發者ID:glowroot,項目名稱:glowroot,代碼行數:21,代碼來源:CollectorLogbackAppender.java

示例13: testEncodeArrayWithNullSuppressedException

import ch.qos.logback.classic.spi.IThrowableProxy; //導入依賴的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

示例14: append

import ch.qos.logback.classic.spi.IThrowableProxy; //導入依賴的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

示例15: append

import ch.qos.logback.classic.spi.IThrowableProxy; //導入依賴的package包/類
@Override
protected void append(ILoggingEvent event) {
    event.prepareForDeferredProcessing();
    //todo do more elegant streaming approach to publish logs

    if (!event.getLevel().equals(Level.ALL) &&         // OFF AND ALL are not loggable levels
            !event.getLevel().equals(Level.OFF)) {
        final IThrowableProxy throwableProxy = event.getThrowableProxy();
        final LogEntry entry = throwableProxy != null ?
                new LogEntry(serverId, event.getFormattedMessage(), Instant.ofEpochMilli(event.getTimeStamp()).toString(),
                        event.getLevel().toString(), event.getLoggerName(), event.getMDCPropertyMap(),
                        event.getThreadName() != null ? event.getThreadName() : null,
                        new Exception(throwableProxy.getMessage(), toStringArray(throwableProxy.getStackTraceElementProxyArray())
                        , throwableProxy.getClassName()))
                : new LogEntry(serverId, event.getFormattedMessage(), Instant.ofEpochMilli(event.getTimeStamp()).toString(),
                event.getLevel().toString(), event.getLoggerName(), event.getMDCPropertyMap(),
                event.getThreadName() != null ? event.getThreadName() : null);
        producer.send(new ProducerRecord<>(kafkaTopic, new Gson().toJson(entry)));
    }
}
 
開發者ID:apache,項目名稱:airavata,代碼行數:21,代碼來源:KafkaAppender.java


注:本文中的ch.qos.logback.classic.spi.IThrowableProxy類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。