java.lang.Object
com.github.eventmanager.internal.ManagerBase
com.github.eventmanager.EventManager
The EventManager class is responsible for managing and logging events.
It provides methods to log messages with different log levels and formats.
-
Field Summary
Fields inherited from class com.github.eventmanager.internal.ManagerBase
eventQueue, logHandler, outputHelper, processingQueue, processorHelper
-
Constructor Summary
ConstructorsConstructorDescriptionEventManager
(LogHandler logHandler) Constructs an EventManager with the specified LogHandler.EventManager
(String configPath) Constructs an EventManager with the specified configuration file path. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks if informational logs are enabled.void
logCustomMessage
(String logLevel, Object message) Logs a message with the specified log level and message.void
logDebugMessage
(EventCreator message) Logs a debug message with a EventCreator message.void
logDebugMessage
(KeyValueWrapper... args) Logs a debug message with key-value pairs.void
logDebugMessage
(Exception exception) Logs a debug message with an exception stack trace.void
logDebugMessage
(Object exception) Logs a debug message.void
logErrorMessage
(EventCreator message) Logs an error message with a EventCreator message.void
logErrorMessage
(KeyValueWrapper... args) Logs an error message with key-value pairs.void
logErrorMessage
(Exception exception) Logs an error message with an exception stack trace.void
logErrorMessage
(Object exception) Logs an error message.void
logFatalMessage
(EventCreator message) Logs a fatal message with a EventCreator message.void
logFatalMessage
(KeyValueWrapper... args) Logs a fatal message with key-value pairs.void
logFatalMessage
(Exception exception) Logs a fatal message with an exception stack trace.void
logFatalMessage
(Object exception) Logs a fatal message.void
logInfoMessage
(EventCreator message) Logs an informational message with a EventCreator message.void
logInfoMessage
(KeyValueWrapper... args) Logs an informational message with key-value pairs.void
logInfoMessage
(Exception exception) Logs an informational message with an exception stack trace.void
logInfoMessage
(Object exception) Logs an informational message.void
logWarningMessage
(EventCreator message) Logs a warning message with a EventCreator message.void
logWarningMessage
(KeyValueWrapper... args) Logs a warning message with key-value pairs.void
logWarningMessage
(Exception exception) Logs a warning message with an exception stack trace.void
logWarningMessage
(Object exception) Logs a warning message.void
Monitors the execution time of a task and logs an error message if it exceeds the specified threshold.static String
setCorrectOSSeperator
(String path) Sets the correct OS-specific file separator in the given path.void
Deprecated.void
Stops the event thread by interrupting it and waiting for it to finish.Methods inherited from class com.github.eventmanager.internal.ManagerBase
addOutput, addProcessor, castExceptionStackTraceToString, initiateThreads, initiateThreads, logMessage, logMessage, outputEvent, outputEvent, removeOutput, removeOutput, removeProcessor, removeProcessor, stopAllThreads, stopAllThreads, writeEventToProcessingQueue, writeEventToQueue
-
Constructor Details
-
EventManager
Constructs an EventManager with the specified LogHandler.- Parameters:
logHandler
- the LogHandler to use for logging events.
-
EventManager
Constructs an EventManager with the specified configuration file path.- Parameters:
configPath
- the path to the configuration file. Passing an empty string or invalid path will force the EventManager to fall back to the default configuration.
-
-
Method Details
-
stopEventThread
Deprecated.UsestopPipeline()
instead.Stops the event thread by interrupting it and waiting for it to finish. This method should be called before shutting down the application to ensure that all events are written to the log file. -
stopPipeline
public void stopPipeline()Stops the event thread by interrupting it and waiting for it to finish. This method should be called before shutting down the application to ensure that all events are written to the log file. -
setCorrectOSSeperator
Sets the correct OS-specific file separator in the given path.- Parameters:
path
- the file path to adjust.- Returns:
- the adjusted file path with the correct OS-specific separator.
-
logCustomMessage
Logs a message with the specified log level and message.- Parameters:
logLevel
- the log level (e.g., "INFO", "ERROR", "DEBUG").message
- the message to log.
-
logFatalMessage
Logs a fatal message.- Parameters:
exception
- the exception to log.
-
logFatalMessage
Logs a fatal message with key-value pairs.- Parameters:
args
- the key-value pairs to log.
-
logFatalMessage
Logs a fatal message with a EventCreator message.- Parameters:
message
- the message to log.
-
logFatalMessage
Logs a fatal message with an exception stack trace.- Parameters:
exception
- the exception to log.
-
logErrorMessage
Logs an error message.- Parameters:
exception
- the exception to log.
-
logErrorMessage
Logs an error message with key-value pairs.- Parameters:
args
- the key-value pairs to log.
-
logErrorMessage
Logs an error message with a EventCreator message.- Parameters:
message
- the message to log.
-
logErrorMessage
Logs an error message with an exception stack trace.- Parameters:
exception
- the exception to log.
-
logWarningMessage
Logs a warning message.- Parameters:
exception
- the exception to log.
-
logWarningMessage
Logs a warning message with key-value pairs.- Parameters:
args
- the key-value pairs to log.
-
logWarningMessage
Logs a warning message with a EventCreator message.- Parameters:
message
- the message to log.
-
logWarningMessage
Logs a warning message with an exception stack trace.- Parameters:
exception
- the exception to log.
-
areInfoLogsEnabled
public boolean areInfoLogsEnabled()Checks if informational logs are enabled.- Returns:
- true if informational logs are enabled, false otherwise.
-
logInfoMessage
Logs an informational message.- Parameters:
exception
- the exception to log.
-
logInfoMessage
Logs an informational message with key-value pairs.- Parameters:
args
- the key-value pairs to log.
-
logInfoMessage
Logs an informational message with a EventCreator message.- Parameters:
message
- the message to log.
-
logInfoMessage
Logs an informational message with an exception stack trace.- Parameters:
exception
- the exception to log.
-
logDebugMessage
Logs a debug message.- Parameters:
exception
- the exception to log.
-
logDebugMessage
Logs a debug message with key-value pairs.- Parameters:
args
- the key-value pairs to log.
-
logDebugMessage
Logs a debug message with a EventCreator message.- Parameters:
message
- the message to log.
-
logDebugMessage
Logs a debug message with an exception stack trace.- Parameters:
exception
- the exception to log.
-
monitor
Monitors the execution time of a task and logs an error message if it exceeds the specified threshold.- Parameters:
operationName
- the name of the operation being monitored.threshold
- the threshold duration for logging a warning message.task
- the task to be executed and monitored.
-
stopPipeline()
instead.