Package io.github.pimak.ntfy.core
Record Class AlertEvent
java.lang.Object
java.lang.Record
io.github.pimak.ntfy.core.AlertEvent
- Record Components:
loggerName- the name of the logger that produced the eventformattedMessage- the fully rendered log message (arguments already substituted)timestampMillis- event time as epoch millisecondscauseChain- the full exception chain surface→root, each element as a(className, message)pair; empty when the event carries no throwablerootCauseFrames- the ROOT cause's stack frames pre-rendered as strings (theStackTraceElement.toString()form), UNLIMITED here — the engine appliesmaxStackFrames; empty when the event carries no throwablemarkerNames- the SLF4J marker names attached to the event (flattened, including composite children); empty on frameworks without markers (e.g. JUL)mdcValues- the ALLOW-LISTED MDC entries only, in configured order, already scrubbed/truncated/capped byMdcProjector— adapters must project viaMdcProjector.project(java.util.List<java.lang.String>, java.util.function.Function<java.lang.String, java.lang.String>)and never pass a raw MDC map; empty on frameworks with no MDC (plain JUL) and wheneverinclude-mdc-keysis unsetlevel- the route this event belongs to;nullis normalized toAlertLevel.ERROR
public record AlertEvent(String loggerName, String formattedMessage, long timestampMillis, List<AlertEvent.Cause> causeChain, List<String> rootCauseFrames, Set<String> markerNames, Map<String,String> mdcValues, AlertLevel level)
extends Record
Framework-neutral snapshot of a single log event, handed to
AlertEngine.submit(io.github.pimak.ntfy.core.AlertEvent). Every
field is a plain JDK type so any logging-framework adapter (logback, log4j2, JUL, ...) can
assemble one without leaking a framework-specific event type into core.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordOne link of an exception chain: the throwable's class name and its message (either may benullin degenerate cases, mirroring the source throwable). -
Constructor Summary
ConstructorsConstructorDescriptionAlertEvent(String loggerName, String formattedMessage, long timestampMillis, List<AlertEvent.Cause> causeChain, List<String> rootCauseFrames, Set<String> markerNames) The pre-mdcValuescanonical signature, kept as an explicit constructor for compatibility:AlertEventis public API, and preserving the original(String, String, long, List, List, Set)descriptor keeps adapters compiled against an earlier release both source- AND binary-compatible — they keep linking without recompilation.AlertEvent(String loggerName, String formattedMessage, long timestampMillis, List<AlertEvent.Cause> causeChain, List<String> rootCauseFrames, Set<String> markerNames, Map<String, String> mdcValues) The pre-levelsignature, kept as an explicit constructor for compatibility, exactly like the pre-mdcValuesone below: preserving the(String, String, long, List, List, Set, Map)descriptor keeps adapters compiled against an earlier release both source- AND binary-compatible.AlertEvent(String loggerName, String formattedMessage, long timestampMillis, List<AlertEvent.Cause> causeChain, List<String> rootCauseFrames, Set<String> markerNames, Map<String, String> mdcValues, AlertLevel level) Validates the mandatory fields and normalizes the optional collections so every construction path — directnew, theof(java.lang.String, java.lang.String, long)factory, or an adapter — yields a null-free, defensively copied event. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thecauseChainrecord component.final booleanIndicates whether some other object is "equal to" this one.Returns the value of theformattedMessagerecord component.final inthashCode()Returns a hash code value for this object.level()Returns the value of thelevelrecord component.Returns the value of theloggerNamerecord component.Returns the value of themarkerNamesrecord component.Returns the value of themdcValuesrecord component.static AlertEventConvenience factory for the "no throwable, no markers" case:causeChain,rootCauseFrames,markerNamesandmdcValuesdefault to empty collections, and the event is anAlertLevel.ERRORone.Returns the value of therootCauseFramesrecord component.longReturns the value of thetimestampMillisrecord component.final StringtoString()Returns a string representation of this record class.withLevel(AlertLevel level) Returns a copy of this event onlevel, leaving every other component untouched.
-
Constructor Details
-
AlertEvent
public AlertEvent(String loggerName, String formattedMessage, long timestampMillis, List<AlertEvent.Cause> causeChain, List<String> rootCauseFrames, Set<String> markerNames, Map<String, String> mdcValues, AlertLevel level) Validates the mandatory fields and normalizes the optional collections so every construction path — directnew, theof(java.lang.String, java.lang.String, long)factory, or an adapter — yields a null-free, defensively copied event.mdcValuesis re-run throughMdcProjector.sanitize(java.util.Map<java.lang.String, java.lang.String>)rather than merely copied: that call is null-safe, order-preserving, and idempotent, so a projection an adapter already produced passes through untouched while an event hand-built by a third party that handed over a raw MDC map is still capped, scrubbed, and truncated here. Only the allow-list SELECTION is the adapter's job; the safety of what ends up in a body is enforced at this boundary.A
nulllevelnormalizes toAlertLevel.ERROR, neverAlertLevel.WARN: an adapter (or third-party caller) that omits the field must fall back to the always-on route, not silently divert its events onto the opt-in quiet channel. -
AlertEvent
public AlertEvent(String loggerName, String formattedMessage, long timestampMillis, List<AlertEvent.Cause> causeChain, List<String> rootCauseFrames, Set<String> markerNames, Map<String, String> mdcValues) The pre-levelsignature, kept as an explicit constructor for compatibility, exactly like the pre-mdcValuesone below: preserving the(String, String, long, List, List, Set, Map)descriptor keeps adapters compiled against an earlier release both source- AND binary-compatible. Delegates atAlertLevel.ERROR, which is the only level those callers could ever have meant. -
AlertEvent
public AlertEvent(String loggerName, String formattedMessage, long timestampMillis, List<AlertEvent.Cause> causeChain, List<String> rootCauseFrames, Set<String> markerNames) The pre-mdcValuescanonical signature, kept as an explicit constructor for compatibility:AlertEventis public API, and preserving the original(String, String, long, List, List, Set)descriptor keeps adapters compiled against an earlier release both source- AND binary-compatible — they keep linking without recompilation. Delegates with an empty MDC map atAlertLevel.ERROR, which is exactly the behavior those callers already had.
-
-
Method Details
-
of
Convenience factory for the "no throwable, no markers" case:causeChain,rootCauseFrames,markerNamesandmdcValuesdefault to empty collections, and the event is anAlertLevel.ERRORone. -
withLevel
Returns a copy of this event onlevel, leaving every other component untouched. Lets an adapter build the event once and then stamp the route onto it, rather than threading the level through every mapper signature. -
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. -
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. -
equals
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
loggerName
Returns the value of theloggerNamerecord component.- Returns:
- the value of the
loggerNamerecord component
-
formattedMessage
Returns the value of theformattedMessagerecord component.- Returns:
- the value of the
formattedMessagerecord component
-
timestampMillis
public long timestampMillis()Returns the value of thetimestampMillisrecord component.- Returns:
- the value of the
timestampMillisrecord component
-
causeChain
Returns the value of thecauseChainrecord component.- Returns:
- the value of the
causeChainrecord component
-
rootCauseFrames
Returns the value of therootCauseFramesrecord component.- Returns:
- the value of the
rootCauseFramesrecord component
-
markerNames
Returns the value of themarkerNamesrecord component.- Returns:
- the value of the
markerNamesrecord component
-
mdcValues
Returns the value of themdcValuesrecord component.- Returns:
- the value of the
mdcValuesrecord component
-
level
Returns the value of thelevelrecord component.- Returns:
- the value of the
levelrecord component
-