Class EventManager


public class EventManager extends ManagerBase
The EventManager class is responsible for managing and logging events. It provides methods to log messages with different log levels and formats.
  • Constructor Details

    • EventManager

      public EventManager(LogHandler logHandler)
      Constructs an EventManager with the specified LogHandler.
      Parameters:
      logHandler - the LogHandler to use for logging events.
    • EventManager

      public EventManager(String configPath)
      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 public void stopEventThread()
      Deprecated.
      Use stopPipeline() 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

      public static String setCorrectOSSeperator(String path)
      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

      public void logCustomMessage(String logLevel, Object message)
      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

      public void logFatalMessage(Object exception)
      Logs a fatal message.
      Parameters:
      exception - the exception to log.
    • logFatalMessage

      public void logFatalMessage(KeyValueWrapper... args)
      Logs a fatal message with key-value pairs.
      Parameters:
      args - the key-value pairs to log.
    • logFatalMessage

      public void logFatalMessage(EventCreator message)
      Logs a fatal message with a EventCreator message.
      Parameters:
      message - the message to log.
    • logFatalMessage

      public void logFatalMessage(Exception exception)
      Logs a fatal message with an exception stack trace.
      Parameters:
      exception - the exception to log.
    • logErrorMessage

      public void logErrorMessage(Object exception)
      Logs an error message.
      Parameters:
      exception - the exception to log.
    • logErrorMessage

      public void logErrorMessage(KeyValueWrapper... args)
      Logs an error message with key-value pairs.
      Parameters:
      args - the key-value pairs to log.
    • logErrorMessage

      public void logErrorMessage(EventCreator message)
      Logs an error message with a EventCreator message.
      Parameters:
      message - the message to log.
    • logErrorMessage

      public void logErrorMessage(Exception exception)
      Logs an error message with an exception stack trace.
      Parameters:
      exception - the exception to log.
    • logWarningMessage

      public void logWarningMessage(Object exception)
      Logs a warning message.
      Parameters:
      exception - the exception to log.
    • logWarningMessage

      public void logWarningMessage(KeyValueWrapper... args)
      Logs a warning message with key-value pairs.
      Parameters:
      args - the key-value pairs to log.
    • logWarningMessage

      public void logWarningMessage(EventCreator message)
      Logs a warning message with a EventCreator message.
      Parameters:
      message - the message to log.
    • logWarningMessage

      public void logWarningMessage(Exception exception)
      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

      public void logInfoMessage(Object exception)
      Logs an informational message.
      Parameters:
      exception - the exception to log.
    • logInfoMessage

      public void logInfoMessage(KeyValueWrapper... args)
      Logs an informational message with key-value pairs.
      Parameters:
      args - the key-value pairs to log.
    • logInfoMessage

      public void logInfoMessage(EventCreator message)
      Logs an informational message with a EventCreator message.
      Parameters:
      message - the message to log.
    • logInfoMessage

      public void logInfoMessage(Exception exception)
      Logs an informational message with an exception stack trace.
      Parameters:
      exception - the exception to log.
    • logDebugMessage

      public void logDebugMessage(Object exception)
      Logs a debug message.
      Parameters:
      exception - the exception to log.
    • logDebugMessage

      public void logDebugMessage(KeyValueWrapper... args)
      Logs a debug message with key-value pairs.
      Parameters:
      args - the key-value pairs to log.
    • logDebugMessage

      public void logDebugMessage(EventCreator message)
      Logs a debug message with a EventCreator message.
      Parameters:
      message - the message to log.
    • logDebugMessage

      public void logDebugMessage(Exception exception)
      Logs a debug message with an exception stack trace.
      Parameters:
      exception - the exception to log.
    • monitor

      public void monitor(String operationName, Duration threshold, Runnable task)
      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.