Class EventCreator
java.lang.Object
com.github.eventmanager.formatters.EventCreator
The EventCreator class is a builder class that creates event logs.
Contrary to the EventFormatter class, it can create event logs with a custom format. The format can be specified by
the user when creating an instance of the EventCreator class. The format can be one of the following: "json", "xml",
"csv", or "key-value".
The class includes information which can be found in the default format, such as the class name, method name, line number, timestamp, level, exception, message, and arguments. These values are generated when creating an instance of the EventCreator class, this should be kept in mind when creating events.
The class includes information which can be found in the default format, such as the class name, method name, line number, timestamp, level, exception, message, and arguments. These values are generated when creating an instance of the EventCreator class, this should be kept in mind when creating events.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAppends the arguments of the log to the event log.args
(String body, KeyValueWrapper args) Appends a key-value pairs o the log to the event log.args
(String body, KeyValueWrapper... args) Appends a number of key-value pairs of the log to the event log.Appends the class name of the log to the event log.create()
Finalizes the event log and returns it as a string.Appends the exception to the event.Appends the level of the log to the event log.Appends the line number of the log to the event log.Appends the message of the log to the event log.Appends the method name of the log to the event log.Appends the timestamp of the log to the event log.
-
Constructor Details
-
EventCreator
The constructor of the EventCreator class.- Parameters:
format
- The format of the event log. The format can be one of the following: "json", "xml", "csv", or "key-value". If the format is not one of the specified formats, the default format is "key-value".
-
-
Method Details
-
lineNumber
Appends the line number of the log to the event log.- Returns:
- The EventCreator object.
-
timestamp
Appends the timestamp of the log to the event log.- Parameters:
timestampFormat
- The format of the timestamp. If the format is not valid, the current timestamp is used. The format should be in the form of a pattern that can be used by the DateTimeFormatter- Returns:
- The EventCreator object.
-
level
Appends the level of the log to the event log.- Parameters:
level
- The level of the log.- Returns:
- The EventCreator object.
-
className
Appends the class name of the log to the event log.- Returns:
- The EventCreator object.
-
methodName
Appends the method name of the log to the event log.- Returns:
- The EventCreator object.
-
exception
Appends the exception to the event.- Parameters:
exception
- The exception of the log.- Returns:
- The EventCreator object.
-
message
Appends the message of the log to the event log.- Parameters:
message
- The message of the log.- Returns:
- The EventCreator object.
-
args
Appends the arguments of the log to the event log.- Parameters:
args
- The arguments of the log.- Returns:
- The EventCreator object.
-
args
Appends a key-value pairs o the log to the event log.- Parameters:
body
- The body of the log.args
- The key-value pair of the argument body.- Returns:
- The EventCreator object.
-
args
Appends a number of key-value pairs of the log to the event log.- Parameters:
body
- The body of the log.args
- The key-value pair of the argument body.- Returns:
- The EventCreator object.
-
create
Finalizes the event log and returns it as a string.- Returns:
- The event log as a string.
-