public static void setStackTraceLogFile(File logFile) { /* close old log file */ if (printStackTrace_Stream != null) { printStackTrace_Stream.close(); printStackTrace_Stream = null; printStackTrace_LogFile = null; } /* open new log file */ if ((logFile != null) && logFile.isAbsolute()) { try { printStackTrace_Stream = new PrintStream(new FileOutputStream(logFile), true); printStackTrace_LogFile = logFile; } catch (IOException ioe) { Print.println(0, "Unable to open StackTrace log file: " + logFile); } } }
public static void dprintStackTrace(PrintStream out, int frame, String title, String msg, Throwable excp) { if (isDebugMode()) { if (out == null) { out = printStackTrace_Stream; } if ((out != null) && (out != System.out) && (out != System.err)) { String m = (excp != null)? (msg + " (" + excp + ")") : msg; Print.println(null, frame + 1, "{log} " + m); } _printStackTrace(out, frame + 1, title, msg, excp); } }
public static void printStackTrace(PrintStream out, int frame, String title, String msg, Throwable excp) { if (out == null) { out = printStackTrace_Stream; } if ((out != null) && (out != System.out) && (out != System.err)) { Print.print("\n"); if (excp != null) { String m = ((msg != null) && !msg.equals(""))? (msg + " - ") : ""; Print.println(null, frame + 1, "Error: " + m + excp + ""); StackTraceElement ste[] = excp.getStackTrace(); if (ste.length > 0) { Print.print(" ==> at " + getStackFrameString(ste[0]) + "\n"); } } else { Print.println(null, frame + 1, msg); } if (printStackTrace_LogFile != null) { Print.print("(Stack trace logged to '" + printStackTrace_LogFile + "')\n"); } Print.print("\n"); } _printStackTrace(out, frame + 1, title, msg, excp); }
for (;st.hasMoreTokens();) { Print.println(out, st.nextToken()); }