Class NTEventLogListener

java.lang.Object
com.iizix.server.NTEventLogListener
All Implemented Interfaces:
ILogHistoryListener

public final class NTEventLogListener extends Object implements ILogHistoryListener
The server log's listener that forwards entries to the Windows NT Event Log (CC-SERVER-RESTART-UPDATE-V5, stage F; NetPhantom's DefaultEventExit filter): SEVERE becomes an error event, WARNING a warning event, INFO an informational event only with the level NTEventLogListener.Level.INFO; CONFIG through FINEST never go. The start options are -ntEventLog off|on|info (default off) and -ntEventSource <name> (default iiziServer), on the command line only (D-21): they are in force before the server settings load, so the first SEVERE of a failing start reaches the event log.

install(File, ServerLogger) enables the log only when the event source is registered, and says so in the server log when it is not: the DLL ends the process (exit code 10) when it has to register the source itself and cannot.

Author:
Christopher Mindus
  • Constructor Details

  • Method Details

    • setLevel

      public static void setLevel(NTEventLogListener.Level l)
      Sets the level from the start option. Not intended to be called but by the launcher.
      Parameters:
      l - The level, null for NTEventLogListener.Level.OFF.
    • getLevel

      public static NTEventLogListener.Level getLevel()
      Gets the level of the start option.
      Returns:
      The level.
    • setSource

      public static void setSource(String name)
      Sets the event source from the start option. Not intended to be called but by the launcher.
      Parameters:
      name - The source, null or blank for the default.
    • getSource

      public static String getSource()
      Gets the event source of the start option.
      Returns:
      The source.
    • eventClass

      public static int eventClass(int logLevel, NTEventLogListener.Level l)
      Maps a log level to an event class.
      Parameters:
      logLevel - ILog.SEVERE .. ILog.FINEST.
      l - The event-log level.
      Returns:
      The event class, or 0 when the entry does not go to the event log.
    • install

      public static NTEventLogListener install(File currentDirectory, ServerLogger logger)
      Installs the listener on a server's logger when the start option asks for it: on Windows, with the event source registered and the DLL of this architecture present. Says in the server log why not otherwise, and never fails the start.
      Parameters:
      currentDirectory - The server's current directory: the installation.
      logger - The server's logger.
      Returns:
      The listener installed, or null.
    • getEventLevel

      public NTEventLogListener.Level getEventLevel()
      Gets the level.
      Returns:
      The level.
    • onInitialized

      public void onInitialized()
      Description copied from interface: ILogHistoryListener
      Called when the history has been reinitialized due to e.g. log file rotation.
      Specified by:
      onInitialized in interface ILogHistoryListener
    • onEntry

      public void onEntry(LogEntry entry)
      Description copied from interface: ILogHistoryListener
      Called when a new history entry is added. This method is only called from the logger queue purger thread, so it is safe to get the history or to manipulate the history at this point. There is no thread synchronization when this method is called.
      Specified by:
      onEntry in interface ILogHistoryListener
      Parameters:
      entry - The entry.