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 ClassesModifier and TypeInterfaceDescriptionstatic final classWhich sections a report includes and how they are rendered.static interfaceImplemented by a component that wants to contribute its own description to a report instead of falling back to just its class name.static enumA section of the report that can be independently turned on or off. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddProperty(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 Stringreport()Renders the report with the default options as a String.default Stringreport(LogReporter.Options options) Renders the report as a String.voidreport(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 aWriter/response even while the system is in a degraded state.default voidreport(LogReporter.Options options, StringBuilder sb) Writes the report to aStringBuilder, which never actually throwsIOExceptionin practice, so callers do not need to handle one.
-
Method Details
-
addProperty
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
Writes the report directly to the given appendable, rather than building the whole report in memory first, so a caller can stream straight into aWriter/response even while the system is in a degraded state. Before aRainbowGumis built from the config,LogReporter.Section.COMPONENTShas no routers to list.- Parameters:
options- which sections to include and how.appendable- destination.- Throws:
IOException- if the appendable throws.
-
report
Writes the report to aStringBuilder, which never actually throwsIOExceptionin practice, so callers do not need to handle one.- Parameters:
options- which sections to include and how.sb- destination.
-
report
Renders the report as a String.- Parameters:
options- which sections to include and how.- Returns:
- report.
-
report
-