Record Class Loggers

java.lang.Object
java.lang.Record
org.mbari.vars.annosaurus.sdk.r1.etc.jdk.Loggers
Record Components:
logger - The logger to use
level - The logging level
cause - The cause of the log message

public record Loggers(System.Logger logger, System.Logger.Level level, Throwable cause) extends Record
Fluent API for logging. This is a simple wrapper around the Java 9+ System.Logger API. It provides a fluent API for logging.
  • Constructor Details

    • Loggers

      public Loggers(System.Logger logger)
    • Loggers

      public Loggers(String loggerName)
    • Loggers

      public Loggers(Class<?> clazz)
    • Loggers

      public Loggers(System.Logger logger, System.Logger.Level level, Throwable cause)
      Creates an instance of a Loggers record class.
      Parameters:
      logger - the value for the logger record component
      level - the value for the level record component
      cause - the value for the cause record component
  • Method Details

    • atTrace

      public Loggers atTrace()
    • atDebug

      public Loggers atDebug()
    • atInfo

      public Loggers atInfo()
    • atWarn

      public Loggers atWarn()
    • atError

      public Loggers atError()
    • withCause

      public Loggers withCause(Throwable t)
    • log

      public void log(String msg)
      Log a message
      Parameters:
      msg - The message to log
    • log

      public void log(Supplier<String> fn)
      Log a message
      Parameters:
      fn - A supplier that returns the message to log
    • logResponse

      public void logResponse(HttpResponse<?> response)
      Log an HTTP response
      Parameters:
      response - The response to log
    • logRequest

      public void logRequest(HttpRequest request, String body)
      Log an HTTP request
      Parameters:
      request - The request to log
      body - The body of the request
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • logger

      public System.Logger logger()
      Returns the value of the logger record component.
      Returns:
      the value of the logger record component
    • level

      public System.Logger.Level level()
      Returns the value of the level record component.
      Returns:
      the value of the level record component
    • cause

      public Throwable cause()
      Returns the value of the cause record component.
      Returns:
      the value of the cause record component