Package net.tangly.commons.logger
Record Class EventData
java.lang.Object
java.lang.Record
net.tangly.commons.logger.EventData
- Record Components:
event
- event triggering the creation of an audit logtimestamp
- timestamp when the audit log was createdcomponent
- component source of the audit log. By convention, we use the module name or if necessary the package namestatus
- status associated with the audit logtext
- text of the audit log. It should be English and provide a concise description of the eventdata
- data specific to the audit logexception
- optional exception to be added to the audit log
public record EventData(@NotNull String event, @NotNull LocalDateTime timestamp, @NotNull String component, @NotNull EventData.Status status, String text, @NotNull Map<String,Object> data, Throwable exception)
extends Record
Provide a simple approach to create an audit trail for all relevant operations performed in the system. Contextual information such as user, IP address are
part of the MDR context and implicitly available to the event data logging process.
Good practice is to log all incoming and outgoing data. The granularity should be an aggregate as defined in the domain-driven design approach. The goal is provide an audit trail for all relevant input and output operations performed in the system.
Statuses are:- Success
- A complex operation was completed successfully. For example all entities of a TSV file could be imported.
- Info
- Status information of a completed system activity. For example one entity of a TSV file could be imported.
- Warning
- The operation encountered a problem but the data could be processed.
- Error
- The data could not be processed due to syntactic or semantic errors.
- Failure
- The operation failed due to an internal or resource problem. For example the file could be found or read.
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
ConstructorDescriptionEventData
(@NotNull String event, @NotNull LocalDateTime timestamp, @NotNull String component, @NotNull EventData.Status status, String text, @NotNull Map<String, Object> data, Throwable exception) Creates an instance of aEventData
record class. -
Method Summary
Modifier and TypeMethodDescription@NotNull String
Returns the value of thecomponent
record component.data()
Returns the value of thedata
record component.final boolean
Indicates whether some other object is "equal to" this one.@NotNull String
event()
Returns the value of theevent
record component.Returns the value of theexception
record component.final int
hashCode()
Returns a hash code value for this object.static void
log
(@NotNull String event, @NotNull String component, @NotNull EventData.Status status, String reason, @NotNull Map<String, Object> data) static void
log
(@NotNull String event, @NotNull String component, @NotNull EventData.Status status, String reason, @NotNull Map<String, Object> data, Throwable exception) static void
Log the event data as audit log.@NotNull EventData.Status
status()
Returns the value of thestatus
record component.text()
Returns the value of thetext
record component.@NotNull LocalDateTime
Returns the value of thetimestamp
record component.final String
toString()
Returns a string representation of this record class.
-
Field Details
-
IMPORT
- See Also:
-
EXPORT
- See Also:
-
FILENAME
- See Also:
-
ENTITY
- See Also:
-
-
Constructor Details
-
EventData
public EventData(@NotNull @NotNull String event, @NotNull @NotNull LocalDateTime timestamp, @NotNull @NotNull String component, @NotNull @NotNull EventData.Status status, String text, @NotNull @NotNull Map<String, Object> data, Throwable exception) Creates an instance of aEventData
record class.- Parameters:
event
- the value for theevent
record componenttimestamp
- the value for thetimestamp
record componentcomponent
- the value for thecomponent
record componentstatus
- the value for thestatus
record componenttext
- the value for thetext
record componentdata
- the value for thedata
record componentexception
- the value for theexception
record component
-
-
Method Details
-
log
-
log
-
log
Log the event data as audit log.- Parameters:
data
- event data to add to the audit trail
-
toString
-
hashCode
-
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. All components in this record class are compared withObjects::equals(Object,Object)
. -
event
-
timestamp
-
component
-
status
-
text
-
data
-
exception
-