List of usage examples for java.lang StackTraceElement getClassName
public String getClassName()
From source file:com.stackify.log.logback.ILoggingEventAdapter.java
/** * @see com.stackify.api.common.log.EventAdapter#getLogMsg(java.lang.Object, com.google.common.base.Optional) *//*w ww.jav a 2 s . c o m*/ @Override public LogMsg getLogMsg(final ILoggingEvent event, final StackifyError error) { LogMsg.Builder builder = LogMsg.newBuilder(); builder.msg(event.getFormattedMessage()); Map<String, String> props = event.getMDCPropertyMap(); if (props != null) { if (!props.isEmpty()) { try { builder.data(json.writeValueAsString(props)); } catch (Exception e) { // do nothing } } } builder.ex(error); builder.th(event.getThreadName()); builder.epochMs(event.getTimeStamp()); builder.level(event.getLevel().toString().toLowerCase()); String transactionId = ServletLogContext.getTransactionId(); if (transactionId != null) { builder.transId(transactionId); } StackTraceElement[] callerData = event.getCallerData(); if (callerData != null) { StackTraceElement locInfo = callerData[0]; if (locInfo != null) { builder.srcMethod(locInfo.getClassName() + "." + locInfo.getMethodName()); try { builder.srcLine(locInfo.getLineNumber()); } catch (Throwable e) { } } } return builder.build(); }
From source file:org.eclipse.jubula.client.ui.rcp.Plugin.java
/** * checks if the exception is caused by a known RCP problem * @param t the Throwable which was caught in the error handler * @return true if the exception was cause by an RCP bug *///from www .j a v a2s.co m public static boolean isRCPException(Throwable t) { Throwable work = t; do { StackTraceElement[] stack = work.getStackTrace(); for (StackTraceElement el : stack) { String className = el.getClassName(); // check for // org.eclipse.ui.views.markers.internal.MarkerAdapter.buildAllMarkers if (className.indexOf("MarkerAdapter") != -1) { //$NON-NLS-1$ return true; } // double click error in help view if (className.indexOf("EngineResultSection") != -1) { //$NON-NLS-1$ return true; } // Context Sensitive Help when DSV Cell Editor is open #3291 if (className.indexOf("ContextHelpPart") != -1) { //$NON-NLS-1$ return true; } // http://bugzilla.bredex.de/84 if (className.indexOf("CompositeImageDescriptor") != -1) { //$NON-NLS-1$ return true; } // http://bugzilla.bredex.de/933 if (className.indexOf("EditorStateParticipant") != -1) { //$NON-NLS-1$ return true; } } // Recursive activation on MacOSX on expand tree item #3618 String detailMessage = work.getMessage(); if (detailMessage != null && detailMessage.indexOf("WARNING: Prevented recursive attempt to activate part") != -1) { //$NON-NLS-1$ return true; } work = work.getCause(); } while (work != null); return false; }
From source file:com.stackify.log.log4j2.LogEventAdapter.java
/** * @see com.stackify.api.common.log.EventAdapter#getClassName(java.lang.Object) *//*ww w . j a v a 2 s. c o m*/ @Override public String getClassName(final LogEvent event) { StackTraceElement source = event.getSource(); if (source != null) { return source.getClassName(); } return null; }
From source file:com.bstek.dorado.idesupport.resolver.RobotResolver.java
protected void assembleError(Document document, Element responseElement, Exception error) { String message = error.getMessage(); if (message == null) { message = error.getClass().getSimpleName(); }//from w ww . j a va 2 s .co m Element messageElement = document.createElement("Message"); messageElement.appendChild(document.createTextNode(message)); responseElement.appendChild(messageElement); Element stackTraceElement = document.createElement("StackTrace"); responseElement.appendChild(stackTraceElement); StackTraceElement[] stackTrace = error.getStackTrace(); for (StackTraceElement ste : stackTrace) { Element element = document.createElement("Element"); element.setAttribute("className", ste.getClassName()); element.setAttribute("methodName", ste.getMethodName()); element.setAttribute("fileName", ste.getFileName()); element.setAttribute("lineNumber", String.valueOf(ste.getLineNumber())); stackTraceElement.appendChild(element); } }
From source file:com.enonic.cms.web.main.UpgradeController.java
/** * Return the formatted cause.//w w w . ja v a 2 s . c o m */ private String getFormattedCause(Throwable cause) { StringBuffer str = new StringBuffer(); str.append("<div class='stacktrace'>"); for (StackTraceElement elem : cause.getStackTrace()) { str.append("<div class='traceelem'>"); str.append(elem.getClassName()).append(".").append(elem.getMethodName()).append(" (line "); str.append(elem.getLineNumber()).append(")"); str.append("</div>"); } str.append("</div>"); return str.toString(); }
From source file:org.openflamingo.remote.thrift.thriftfs.ThriftHandlerBase.java
/** * Return a list of threads that currently exist with their stack traces *///w w w . ja v a 2 s . c om public List<ThreadStackTrace> getThreadDump(RequestContext ctx) { List<ThreadStackTrace> dump = new ArrayList<ThreadStackTrace>(); Map<Thread, StackTraceElement[]> traces = Thread.getAllStackTraces(); for (Map.Entry<Thread, StackTraceElement[]> entry : traces.entrySet()) { final Thread t = entry.getKey(); final StackTraceElement[] frames = entry.getValue(); ThreadStackTrace tst = new ThreadStackTrace(); tst.threadName = t.getName(); tst.threadStringRepresentation = String.valueOf(t); tst.isDaemon = t.isDaemon(); tst.stackTrace = new ArrayList<StackTraceElement>(); for (StackTraceElement ste : frames) { StackTraceElement tFrame = new StackTraceElement(); tFrame.className = ste.getClassName(); tFrame.fileName = ste.getFileName(); tFrame.lineNumber = ste.getLineNumber(); tFrame.methodName = ste.getMethodName(); tFrame.isNativeMethod = ste.isNativeMethod(); tFrame.stringRepresentation = String.valueOf(ste); tst.stackTrace.add(tFrame); } dump.add(tst); } return dump; }
From source file:org.kantega.notsoserial.DefaultNotSoSerial.java
private void registerDeserialization(String className) { if (!deserializingClasses.contains(className)) { deserializingClasses.add(className); String prettyName = className.replace('/', '.'); dryRunWriter.println(prettyName); dryRunWriter.flush();/*from w ww .j av a 2 s .c om*/ if (traceWriter != null) { traceWriter .println("Deserialization of class " + prettyName + " (on " + new Date().toString() + ")"); boolean foundReadObject = false; for (StackTraceElement element : Thread.currentThread().getStackTrace()) { if (foundReadObject) { traceWriter.println("\t at " + element.getClassName() + "." + element.getMethodName()); } else if (element.getClassName().equals(ObjectInputStream.class.getName()) && element.getMethodName().equals("readObject")) { foundReadObject = true; } } } } }
From source file:org.jtrfp.trcl.flow.GameShell.java
private void throwable2StringBuilder(Throwable e, StringBuilder sb) { assert e != null; assert sb != null; sb.append(e.getClass().getName() + " " + e.getLocalizedMessage() + "\n"); final StackTraceElement[] stackTraceElements = e.getStackTrace(); for (StackTraceElement ste : stackTraceElements) sb.append("\tat " + ste.getClassName() + "." + ste.getMethodName() + "(" + ste.getFileName() + ":" + ste.getLineNumber() + ")\n"); }
From source file:com.zacwolf.commons.wbxcon.WBXCONorg.java
private final static String getMethodName(final int level) { final StackTraceElement element = Thread.currentThread().getStackTrace()[level]; return element.getClassName() + "." + element.getMethodName(); }
From source file:com.l2jfree.mmocore.network.MMOLogger.java
private void log(Level level, String message, Throwable throwable) { if (_logger.isLoggable(level)) { final StackTraceElement caller = new Throwable().getStackTrace()[2]; final String className = caller.getClassName(); final String methodName = caller.getMethodName(); final MMOLogEntry entry = new MMOLogEntry(level, className, methodName, message, throwable); synchronized (_logEntries) { final Integer count = _logEntries.get(entry); _logEntries.put(entry, count == null ? 1 : count + 1); }/* ww w.jav a 2 s .c o m*/ } }