Class LogFormatter.ThrowableFormatter.Builder

java.lang.Object
io.jstach.rainbowgum.LogFormatter.ThrowableFormatter.Builder
Enclosing interface:
LogFormatter.ThrowableFormatter

  • Method Details

    • maxLines

      Maximum number of stack frame ("at ...") lines printed per throwable in the chain. Use Integer.MAX_VALUE for no limit (the default, and matches LogFormatter.ThrowableFormatter.of() for well behaved throwables). 0 prints just the throwable header lines (class and message) for the whole chain with no frames at all.
      Parameters:
      maxLines - maximum stack frame lines per throwable.
      Returns:
      this builder.
    • excludes

      Regular expressions matched with Matcher.find() against each frame's StackTraceElement.toString(). A frame matching any of these is omitted entirely and does not count against maxLines(int). Defaults to empty (no filtering).
      Parameters:
      excludes - exclude patterns.
      Returns:
      this builder.
    • packagingData

      Whether to append packaging data (the jar or module a frame's class was loaded from, and its version) after each frame line, e.g. [myapp-1.0.jar:1.0] or [java.base:na]. This mirrors (but does not byte-for-byte match) logback's ExtendedThrowableProxyConverter output. Resolution requires loading the frame's class (without initializing it) and can fail silently to [na:na] for frames whose class cannot be loaded (e.g. dynamically generated classes). This has a real per-frame cost so it defaults to false.
      Parameters:
      packagingData - true to append packaging data.
      Returns:
      this builder.
    • rootCauseFirst

      Whether to print the root cause first instead of last, working back up through each wrapping exception ("Wrapped by: ..." instead of "Caused by: ..."), mirroring logback's RootCauseFirstThrowableProxyConverter (%rEx/ %rootException). Frame trimming (common-frame elision against each throwable's own wrapper, maxLines(int), excludes(List)) behaves identically either way - only the print order and the "Caused by:"/"Wrapped by:" captions differ. Defaults to false.
      Parameters:
      rootCauseFirst - true to print the root cause first.
      Returns:
      this builder.
    • build

      Builds the formatter. If none of maxLines(int), excludes(List), packagingData(boolean), or rootCauseFirst(boolean) were set away from their defaults, returns LogFormatter.ThrowableFormatter.of() (i.e. plain Throwable.printStackTrace() behavior) instead of constructing a formatter that walks the throwable manually for no reason.
      Returns:
      formatter.