Class StackTraceInfo

java.lang.Object
com.seeq.utilities.process.StackTraceInfo

public final class StackTraceInfo extends Object
Collection of utilities for retrieving, formatting, and displaying information related to call stacks.
  • Constructor Details

    • StackTraceInfo

      public StackTraceInfo()
  • Method Details

    • getFullStackTrace

      public static String getFullStackTrace(StackTraceElement[] stack)
      Retrieve a full stack trace suitable for verbose log output.
      Parameters:
      stack - The stack trace to print out.
      Returns:
      A multi-line stack trace with each call on its own line
    • getSimpleStackTrace

      public static String getSimpleStackTrace(int frameCount)
      Retrieve an abbreviated stack trace for the current thread that fits on a single line. Intended for log output.
      Parameters:
      frameCount - The number of frames to include in the stack trace. Example: If this method is called from a method called test(), use frameCount=2 to output a stack trace that includes test() and the method that invoked it.
      Returns:
      A single-line string for the stack trace, or "No stack information available" if no stack trace information was found.
    • getSimpleStackTrace

      public static String getSimpleStackTrace(StackTraceElement[] stack, int frameCount)
      Retrieve an abbreviated stack trace that fits on a single line. Intended for log output.
      Parameters:
      stack - The stack trace to print out.
      frameCount - The number of frames to include in the stack trace. Example: If this method is called from a method called test(), use frameCount=2 to output a stack trace that includes test() and the method that invoked it.
      Returns:
      A single-line string for the stack trace, or "No stack information available" if no stack trace information was found.
    • getSimpleStackTrace

      public static String getSimpleStackTrace(StackTraceElement[] stack, int minFrameCount, int maxFrameCount)
      Retrieve an abbreviated stack trace that fits on a single line. Intended for log output.
      Parameters:
      stack - The stack trace to print out.
      minFrameCount - The first frame to output. 0 will contain the method where the stack trace was taken, which may not be desirable.
      maxFrameCount - The number of frames to include in the stack trace. Example: If this method is called from a method called test(), use frameCount=2 to output a stack trace that includes test() and the method that invoked it.
      Returns:
      A single-line string for the stack trace, or "No stack information available" if no stack trace information was found.