Formatters Module
This module contains classes and functions related to formatters in the EventManager.
- class EventManager.formatters.JsonFormatter[source]
Bases:
DefaultFormatter
- class EventManager.formatters.KeyValueFormatter[source]
Bases:
DefaultFormatter
- class EventManager.formatters.EventCreator(format='key-value')[source]
Bases:
objectThe 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.
- line_number() EventCreator[source]
Appends the line number to the event log.
- Returns:
The EventCreator instance.
- class_name() EventCreator[source]
Appends the class name to the event log.
- Returns:
The EventCreator instance.
- method_name() EventCreator[source]
Appends the method name to the event log.
- Returns:
The EventCreator instance.
- timestamp(timestamp_format: str) EventCreator[source]
Appends the timestamp to the event log.
- Returns:
The EventCreator instance.
- level(level: str) EventCreator[source]
Appends the level to the event log.
- Parameters:
level – The level of the event log.
- Returns:
The EventCreator instance.
- fatal_level() EventCreator[source]
Appends the fatal level to the event log.
- Returns:
The EventCreator instance.
- error_level() EventCreator[source]
Appends the error level to the event log.
- Returns:
The EventCreator instance.
- warning_level() EventCreator[source]
Appends the warning level to the event log.
- Returns:
The EventCreator instance.
- info_level() EventCreator[source]
Appends the info level to the event log.
- Returns:
The EventCreator instance.
- debug_level() EventCreator[source]
Appends the debug level to the event log.
- Returns:
The EventCreator instance.
- exception(exception: Exception) EventCreator[source]
Appends the exception to the event log.
- Parameters:
exception – The exception to append.
- Returns:
The EventCreator instance.
- message(message: str) EventCreator[source]
Appends the message to the event log.
- Parameters:
message – The message to append.
- Returns:
The EventCreator instance.
- arguments(*args) EventCreator[source]
Appends the arguments to the event log.
- Parameters:
args – The arguments to append.
- Returns:
The EventCreator instance.
- thread_id() EventCreator[source]
Appends the thread ID to the event log.
- Returns:
The EventCreator instance.
- thread_name() EventCreator[source]
Appends the thread name to the event log.
- Returns:
The EventCreator instance.
- hostname() EventCreator[source]
Appends the hostname to the event log.
- Returns:
The EventCreator instance.
- ip_address() EventCreator[source]
Appends the IP address to the event log.
- Returns:
The EventCreator instance.
- class EventManager.formatters.KeyValueWrapper(key: str, value: str)[source]
Bases:
objectA class to wrap a key-value pair.
- class EventManager.formatters.CsvFormatter[source]
Bases:
DefaultFormatterCsvFormatter is a class that formats event data into CSV format.