List of usage examples for java.lang Throwable Throwable
public Throwable()
From source file:org.apache.jk.common.MsgAjp.java
private void cpBytes(byte b[], int off, int numBytes) { if (pos + numBytes >= buf.length) { log.error("Buffer overflow: buffer.len=" + buf.length + " pos=" + pos + " data=" + numBytes); dump("Overflow/coBytes"); log.error("Overflow ", new Throwable()); return;/*from www . j ava 2 s . c om*/ } System.arraycopy(b, off, buf, pos, numBytes); pos += numBytes; // buf[pos + numBytes] = 0; // Terminating \0 }
From source file:io.stallion.services.Log.java
/** * Logs a message, setting the class, method and source line number using the stack frame index passed in. * This is useful if you are wrapping a logging class, and want to include the line number from where * the wrapper method is called./*from w ww . j a v a 2 s .com*/ * * @param frame - the stack frame to use. Use '2' to log to one level above the caller * @param level * @param message * @param args */ public static void logForFrame(int frame, Level level, String message, Object... args) { if (getLogLevel().intValue() > level.intValue()) { return; } Throwable t = new Throwable(); StackTraceElement stackTraceElement = t.getStackTrace()[frame]; String clz = stackTraceElement.getClassName().replace("io.stallion.", ""); String method = stackTraceElement.getMethodName() + ":" + t.getStackTrace()[frame].getLineNumber(); logger.logp(level, clz, method, message, args); }
From source file:org.o3project.ocnrm.odenos.driver.AbstractDriver.java
@Override protected final Response onRequest(final Request request) { logger.info(seqNo + "\t-- " + new Throwable().getStackTrace()[0].getMethodName() + " Start"); logger.debug("received {}", request.path); final RequestParser<IActionCallback>.ParsedRequest parsed = parser.parse(request); if (parsed == null) { logger.error("ParsedRequest is null."); return new Response(Response.BAD_REQUEST, "Error unknown request "); }//from w w w . j a v a 2 s . co m final IActionCallback callback = parsed.getResult(); if (callback == null) { logger.error("IActionCallback is null."); return new Response(Response.BAD_REQUEST, "Error unknown request "); } service.submit(new Callable<Response>() { public Response call() { try { return callback.process(parsed); } catch (Exception e) { e.printStackTrace(); logger.error("Exception is occurred."); return new Response(Response.BAD_REQUEST, "Error unknown request "); } } }); return new Response(Response.OK, ""); }
From source file:alluxio.util.io.PathUtils.java
/** * Creates a unique path based off the caller. * * @return unique path based off the caller *//* ww w . j a v a 2s.co m*/ public static String uniqPath() { StackTraceElement caller = new Throwable().getStackTrace()[1]; long time = System.nanoTime(); return "/" + caller.getClassName() + "/" + caller.getMethodName() + "/" + time; }
From source file:com.google.gdt.eclipse.designer.gxt.databinding.model.bindings.FieldBindingInfo.java
@Override public AstObjectInfo parseExpression(AstEditor editor, String signature, MethodInvocation invocation, Expression[] arguments, IModelResolver resolver, IDatabindingsProvider provider) throws Exception { if (BIND.equals(signature)) { BeansObserveTypeContainer container = DatabindingsProvider.cast(provider).getBeansContainer(); BeanObserveInfo beanObserveObject = container.getBeanObserveObject(arguments[0]); setModel(beanObserveObject, beanObserveObject.resolvePropertyReference(m_parsedProperty, null)); ///*from w w w .j ava 2 s.com*/ provider.getBindings().add(this); } else if (signature.startsWith(SET_STORE_START)) { m_storeReference = CoreUtils.getNodeReference(arguments[0]); } else if (SET_CONVERTER.equals(signature)) { m_converter = (ConverterInfo) resolver.getModel(arguments[0]); if (m_converter == null) { AbstractParser.addError(editor, "FieldBinding converter '" + arguments[0] + "' not found", new Throwable()); } } return null; }
From source file:org.nuxeo.client.api.objects.NuxeoEntity.java
protected String getCurrentMethodName() { StackTraceElement stackTraceElements[] = (new Throwable()).getStackTrace(); return stackTraceElements[2].getMethodName(); }
From source file:org.ebayopensource.turmeric.eclipse.core.logging.SOALogger.java
/** * The logger name is automatically obtained. * @return An instance of <code>LogManager</code> *//*from www .ja va 2 s . c o m*/ public static SOALogger getLogger() { StackTraceElement[] elements = new Throwable().getStackTrace(); return getLogger(elements[1].getClassName()); }
From source file:io.stallion.services.Log.java
public static void exception(Throwable ex, String message, Object... args) { HealthTracker.instance().logException(ex); if (getLogLevel().intValue() > Level.SEVERE.intValue()) { return;// w w w . j a v a 2 s . co m } if (args.length > 0) { message = MessageFormat.format(message, args); } // TODO: WTF -- figure out how the hell the handler got removed; if (logger.getHandlers().length == 0) { logger.addHandler(handler); } Throwable t = new Throwable(); StackTraceElement stackTraceElement = t.getStackTrace()[1]; String clz = stackTraceElement.getClassName().replace("io.stallion.", ""); String method = stackTraceElement.getMethodName() + ":" + t.getStackTrace()[1].getLineNumber(); logger.logp(Level.SEVERE, clz, method, message, ex); }
From source file:org.apache.sqoop.connector.jdbc.oracle.util.OracleUtilities.java
public static String getCurrentMethodName() { StackTraceElement[] stackTraceElements = (new Throwable()).getStackTrace(); return String.format("%s()", stackTraceElements[1].getMethodName()); }
From source file:mSearch.tool.Log.java
private static void fehlermeldung_(int fehlerNummer, Exception ex, String[] texte) { final Throwable t = new Throwable(); final StackTraceElement methodCaller = t.getStackTrace()[2]; final String klasse = methodCaller.getClassName() + "." + methodCaller.getMethodName(); String kl;// w ww .j av a2 s . c o m try { kl = klasse; while (kl.contains(".")) { if (Character.isUpperCase(kl.charAt(0))) { break; } else { kl = kl.substring(kl.indexOf(".") + 1); } } } catch (Exception ignored) { kl = klasse; } addFehlerNummer(fehlerNummer, kl, ex != null); if (ex != null || Config.debug) { // Exceptions immer ausgeben resetProgress(); String x, z; if (ex != null) { x = "!"; } else { x = "="; } z = "*"; logList.add(x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x); try { // Stacktrace try (StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw)) { if (ex != null) { ex.printStackTrace(pw); } pw.flush(); sw.flush(); logList.add(sw.toString()); } } catch (Exception ignored) { } logList.add(z + " Fehlernr: " + fehlerNummer); if (ex != null) { logList.add(z + " Exception: " + ex.getMessage()); } logList.add(z + " " + FEHLER + kl); for (String aTexte : texte) { logList.add(z + " " + aTexte); } logList.add(""); printLog(); } }