Interface LogReporter


public sealed interface LogReporter
Renders a diagnostic report of a LogConfig and, once one is built from it, its RainbowGum. Each config has its own reporter, see LogConfig.reporter(). Which sections are included (LogReporter.Section.VERSION, LogReporter.Section.COMPONENTS, LogReporter.Section.METRICS, LogReporter.Section.ALERTS, ...) is chosen per report with LogReporter.Options.

Components that read a property worth seeing in every report add its key with addProperty(Class, String), and LogReporter.Section.COMPONENTS lists those keys with their current values and the packages that added them.

API Note
The rendered output's format carries no compatibility guarantee whatsoever. It is meant to be read by a human, or an agent, while setting things up or debugging an incident, not parsed by anything expecting a stable schema, and may change between any two releases including patch releases.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final class 
    Which sections a report includes and how they are rendered.
    static interface 
    Implemented by a component that wants to contribute its own description to a report instead of falling back to just its class name.
    static enum 
    A section of the report that can be independently turned on or off.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addProperty(Class<?> source, String key)
    Adds a property key whose current value is included in every report, attributed to the package of the given class.
    default String
    Renders the report with the default options as a String.
    default String
    Renders the report as a String.
    void
    report(LogReporter.Options options, Appendable appendable)
    Writes the report directly to the given appendable, rather than building the whole report in memory first, so a caller can stream straight into a Writer/response even while the system is in a degraded state.
    default void
    Writes the report to a StringBuilder, which never actually throws IOException in practice, so callers do not need to handle one.
  • Method Details

    • addProperty

      void addProperty(Class<?> source, String key)
      Adds a property key whose current value is included in every report, attributed to the package of the given class. Adding the same key from the same package again has no effect; adding it from another package adds that package to the key's attribution.
      Parameters:
      source - class reading the property.
      key - full property key.
    • report

      void report(LogReporter.Options options, Appendable appendable) throws IOException
      Writes the report directly to the given appendable, rather than building the whole report in memory first, so a caller can stream straight into a Writer/response even while the system is in a degraded state. Before a RainbowGum is built from the config, LogReporter.Section.COMPONENTS has no routers to list.
      Parameters:
      options - which sections to include and how.
      appendable - destination.
      Throws:
      IOException - if the appendable throws.
    • report

      default void report(LogReporter.Options options, StringBuilder sb)
      Writes the report to a StringBuilder, which never actually throws IOException in practice, so callers do not need to handle one.
      Parameters:
      options - which sections to include and how.
      sb - destination.
    • report

      default String report(LogReporter.Options options)
      Renders the report as a String.
      Parameters:
      options - which sections to include and how.
      Returns:
      report.
    • report

      default String report()
      Renders the report with the default options as a String.
      Returns:
      report.
      See Also: