Class KubeVirtLog

java.lang.Object
io.jenkins.plugins.kubevirt.KubeVirtLog

public final class KubeVirtLog extends Object
Centralised helper for writing timestamped [KubeVirt …] messages to agent console logs.

System-level logs (via java.util.logging) already carry timestamps, but agent console output written through TaskListener does not. This utility adds a UTC timestamp to every line so that operators can correlate agent activity with system events and measure provisioning durations.

The format mirrors the Jenkins SSH launcher convention so that all agent log entries share a consistent layout:

 [03/05/26 12:20:07] [KubeVirt] VM provisioning complete, launching SSH connection...
 
  • Method Details

    • log

      public static void log(@NonNull PrintStream out, @NonNull String message)
      Prints a timestamped [KubeVirt …] line to the agent log.
      Parameters:
      out - the agent console PrintStream
      message - the message to print (without prefix)
    • error

      public static void error(@NonNull TaskListener listener, @NonNull String message)
      Prints a timestamped [KubeVirt] ERROR: … line to the agent log.

      We intentionally write through PrintStream.println() rather than TaskListener.error(String, Object...) because the latter is a Formatter-based API. Any % character that appears in an exception message (e.g. "CPU at 100% load") would be misinterpreted as a format specifier and throw MissingFormatArgumentException at runtime.

      Parameters:
      listener - the task listener
      message - the error message (without prefix)
    • messageOf

      @NonNull public static String messageOf(@NonNull Throwable t)
      Returns a non-null, human-readable description of a throwable.

      If the exception carries a message, that message is returned. Otherwise the simple class name is used (e.g. "NullPointerException") so that log lines never contain a bare "null" string.

      Parameters:
      t - the throwable
      Returns:
      a description suitable for log messages