java.lang.Object
org.creekservice.internal.observability.logging.structured.DefaultLogEntryCustomizer
All Implemented Interfaces:
LogEntryCustomizer

public final class DefaultLogEntryCustomizer extends Object implements LogEntryCustomizer
Default impl of the LogEntryCustomizer type.
  • Method Details

    • create

      public static DefaultLogEntryCustomizer create(String messageText)
      Factory method
      Parameters:
      messageText - the text message to log
      Returns:
      the log customizer.
    • ns

      public DefaultLogEntryCustomizer ns(String namespace)
      Description copied from interface: LogEntryCustomizer
      Nest the log entry within a namespace.

      Namespacing log entries can make it easier to filter logs.

      The method can be called multiple times to nest within multiple namespace.

      Specified by:
      ns in interface LogEntryCustomizer
      Parameters:
      namespace - the name of the namespace.
      Returns:
      self.
    • with

      public LogEntryCustomizer with(String key, Object value)
      Description copied from interface: LogEntryCustomizer
      Attach a key-value pair to the log entry.

      Use this method to attach metrics or values to the log entry. Such metrics will be output in a standard format, making them much more machine-readable.

      Specified by:
      with in interface LogEntryCustomizer
      Parameters:
      key - the name of the metric / value.
      value - the value to log, converted to a string via toString(). Null values are ignored.
      Returns:
      self
    • withThrowable

      public LogEntryCustomizer withThrowable(Throwable t)
      Description copied from interface: LogEntryCustomizer
      Attach an exception or error to the log entry.

      The throwable will be passed down to the underlying logging system. This normally results in the stack trace being included in the log entry.

      Specified by:
      withThrowable in interface LogEntryCustomizer
      Parameters:
      t - the throwable to attach.
      Returns:
      self
    • build

      public Map<String,​Object> build()
      Build the log entry
      Returns:
      the structured log entry
    • throwable

      public Optional<Throwable> throwable()
      Returns:
      any throwable set.