Class PanelConnectionLog

java.lang.Object
com.ultikits.ultitools.websocket.PanelConnectionLog

@Internal public final class PanelConnectionLog extends Object
Writes the framework's lines about the panel connection itself to the server console, marked so the panel's log stream never sends them back to the panel (as of 6.3.0).

Why the mark exists. The panel answers a message it rejects with an error reply, and it counts the rejected message against the client's quota (50 messages in 10 seconds). The framework used to log each error reply as a SEVERE line through the shared plugin logger; the log stream sent that line to the panel, the panel rejected it as over quota and replied with another error. Measured on a real server with ultipanel.logging.batch.enabled: false: 42,066 "Rate limit exceeded" lines in one run. SystemLogHandler's same-thread guard cannot stop this, because each reply is a separate inbound message, and its logger-name filter cannot either, because every line logged through the shared plugin logger carries that logger's name.

What it covers. Every line whose text comes from the panel connection or describes it: the panel's replies and notifications, inbound messages the framework cannot use, the client's connect, disconnect, heartbeat and reconnect lines, and the warnings about a message that could not be sent. Lines about work the panel asked for (a command, a file operation) are not connection lines and stay on the stream.

How. The line is logged through the plugin logger as before -- so it reaches the console with the plugin's own [UltiTools] prefix and at its real level -- but as a record of a private LogRecord subclass. SystemLogHandler never hands a record for which isPanelConnectionRecord(LogRecord) is true to the stream (its error report for a SEVERE record with an exception still runs), and EarlyLogCapture does not keep one. Paper's plugin logger hands the same record object to every handler up the logger chain, so the mark survives the trip to the root logger. A dedicated logger was not used because the console prints a record's logger name as its bracketed prefix, so these lines would lose the [UltiTools] prefix operators search for.

Since:
6.3.0
  • Constructor Details

    • PanelConnectionLog

      private PanelConnectionLog()
  • Method Details

    • log

      public static void log(Level level, String message)
      Logs a panel-connection line through the plugin logger.
      Parameters:
      level - the level
      message - the text, already formatted
    • log

      public static void log(Level level, String message, Throwable thrown)
      Logs a panel-connection line, with its exception, through the plugin logger. Nothing is written when the plugin instance or its logger is not available (a call before the plugin is enabled, or a unit test without one).
      Parameters:
      level - the level
      message - the text, already formatted
      thrown - the exception, or null
    • isPanelConnectionRecord

      public static boolean isPanelConnectionRecord(LogRecord record)
      Whether record was written by this class, and so must not be sent to the panel.
      Parameters:
      record - the record, possibly null
      Returns:
      whether it is a panel-connection line