Class Debug

java.lang.Object
de.spiritscorp.datasync.io.Debug

public final class Debug extends Object
Utility class providing centralized logging capabilities for application diagnostics, errors, and exception tracking. All outputs are automatically enriched with a timestamp and the active application instance name.
  • Method Details

    • printDebug

      public static void printDebug(String format, Object... args)
      Writes a formatted debugging message to the standard output stream (stdout). The output is automatically prefixed with a current timestamp and the running instance name.
      Parameters:
      format - A format string as described in Formatter syntax
      args - Arguments referenced by the format specifiers in the format string. If there are more arguments than format specifiers, the extra arguments are ignored. The number of arguments is variable and may be zero. The maximum number of arguments is limited by the maximum dimension of a Java array as defined by The Java Virtual Machine Specification.
    • printError

      public static void printError(String format, Object... args)
      Writes a formatted error message to the standard error stream (stderr). The output is automatically prefixed with a current timestamp and the running instance name.
      Parameters:
      format - A format string as described in Formatter syntax
      args - Arguments referenced by the format specifiers in the format string. If there are more arguments than format specifiers, the extra arguments are ignored. The number of arguments is variable and may be zero. The maximum number of arguments is limited by the maximum dimension of a Java array as defined by The Java Virtual Machine Specification.
    • printException

      public static void printException(Class<?> clazz, Exception exception)
      Logs or prints detailed diagnostic information about a caught exception.

      This utility method formats and outputs the primary exception message, inspects and logs the root cause if present to prevent NullPointerException, and extracts the complete formatted stack trace for deep debugging.

      * Example Output Structure:

      Exception in Class: [com.example.MyService]:Message -> Connection failed
      ↳ Cause: java.net.ConnectException -> Message: Connection refused
      Full Info:
      java.lang.RuntimeException: Connection failed
      at com.example.MyService.start(MyService.java:24)
      ...
      

      Parameters:
      clazz - the Class context where the exception was caught, used for identification
      exception - the Exception instance containing the error details and stack trace
    • printDebugTimeless

      public static void printDebugTimeless(String format, Object... args)
      A debug method to write a formatted string to this output stream using the specified format string and arguments.
      Parameters:
      format - A format string as described in Formatter syntax
      args - Arguments referenced by the format specifiers in the format string. If there are more arguments than format specifiers, the extra arguments are ignored. The number of arguments is variable and may be zero. The maximum number of arguments is limited by the maximum dimension of a Java array as defined by The Java Virtual Machine Specification.
    • setDebugToFile

      public static void setDebugToFile()
      Redirects diagnostic logging output streams to a local file. Once invoked, messages processed by this utility will be appended to the designated log file infrastructure instead of solely printing to the console.