Internal Module
This module contains internal utilities and functions for the EventManager.
- class EventManager.internal.ManagerBase(log_handler=None, config_path: str = None)[source]
Bases:
objectThe ManagerBase is the base class for the EventManager and InternalEventManager. It handles the initialization of the log handler, event processing, and output management.
- property log_handler
Returns the LogHandler instance.
- output_event(event: str, internal_event_manager=None)[source]
Passes the event to the output destinations.
- log_message(level: str, *messages)[source]
Formats and queues a log message for processing and eventual writing to log file.
- Parameters:
level – Log level (e.g., INFO, ERROR).
messages – A single message (Exception or str), or multiple KeyValueWrapper instances.
- add_output(output_entry: OutputEntry) bool[source]
Adds a new output destination based on the provided OutputEntry. :param output_entry: The OutputEntry instance containing the output configuration. :return: True if the output was added successfully, False otherwise.
- remove_output(output)[source]
Removes an output destination.
- Parameters:
output – Either an OutputEntry object or a class name as a string.
- Returns:
True if the output was removed successfully, False otherwise.
- add_processor(processor)[source]
Adds a processor to the processing queue.
- Parameters:
processor – The processor to be added.
- remove_processor(processor: ProcessorEntry = None, processor_name: str = None)[source]
Removes a processor from the processing queue.
- Parameters:
processor – The processor to be removed.
processor_name – The name of the processor to be removed.
- class EventManager.internal.EventMetaDataBuilder[source]
Bases:
objectUtility class responsible for constructing event metadata.
Event metadata typically contains contextual information such as: - Timestamp indicating when the event occurred. - The log level associated with the event. - Class name where the log method was invoked. - Method name from which the event was logged. - The exact line number within the source file.
- static build_metadata(level, log_handler)[source]
Constructs a metadata dictionary containing contextual information about a logged event.
- Parameters:
level – The severity or informational level of the logged event (e.g., INFO, ERROR, DEBUG).
log_handler – The LogHandler instance providing configuration, such as timestamp formatting details.
- Returns:
A dictionary containing event metadata with keys: “time”, “level”, “className”, “methodName”, and “lineNumber”.
- class EventManager.internal.OutputHelper(log_handler: LogHandler)[source]
Bases:
objectA helper class to manage output instances for the EventManager.
- get_output(parameters: dict, clazz) Output[source]
Creates an output instance based on the provided class name and parameters. :param parameters: The parameters for the output instance. :param clazz: The class of the output instance to create. :return: An instance of the output class or None if the class is not recognized.
- output_event(event: str, internal_event_manager=None)[source]
Outputs the event to all output destinations.
- Parameters:
event – The event message to output.
internal_event_manager – Optional custom event manager to use for writing. Defaults to self._log_handler if not provided.
- add_output(output_entry) bool[source]
Adds a new output destination based on the provided OutputEntry. :param output_entry: The OutputEntry instance containing the output configuration. :return:
- class EventManager.internal.ProcessorHelper(log_handler)[source]
Bases:
objectThe ProcessorHelper class is responsible for managing and processing events
- process_event(event: str)[source]
Processes an event by passing it through all registered processors.
- Parameters:
event – The event to process.
- Returns:
The processed event.
- initialise_processors()[source]
Initializes the processors by creating instances based on the configuration. :return:
- add_processor(processor_entry)[source]
Adds a processor to the list of registered processors. :param processor_entry: The processor entry to add. :return: True if the processor was added, False otherwise.
- remove_processor_by_name(processor_name)[source]
Removes a processor by its name from the list of registered processors. :param processor_name: The name of the processor to remove. :return: True if the processor was removed, False otherwise.
- remove_processor(identifier: str | ProcessorEntry) bool[source]
Removes a processor from the list of registered processors based on the provided identifier. :param identifier: Either a string representing the processor name or a ProcessorEntry object. :return: True if the processor was removed, False otherwise.
- class EventManager.internal.ThreadHelper[source]
Bases:
objectA helper class to manage threads in the EventManager.
- property event_thread
Returns the event thread. :return:
- property processing_thread
Returns the processing thread. :return:
- start_event_thread(runnable: callable)[source]
Starts the event thread with the given runnable function. :param runnable: :return: