Class LogHandler


  • public class LogHandler
    extends java.util.logging.Handler
    Log handler which can provide a window displaying recent log events.
    Since:
    5 Aug 2021
    Author:
    Mark Taylor (Starlink)
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int RING_SIZE
      Maximum number of log records retained.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected LogHandler()
      Constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      void flush()  
      static LogHandler getInstance()
      Returns the standard instance of this class.
      java.awt.Color getRecordColor​(java.util.logging.LogRecord record)
      Maps log records to display colours.
      void publish​(java.util.logging.LogRecord record)  
      void showWindow​(java.awt.Component parent)
      Displays a logging window which displays recent (the last 1000) and any future log messages.
      • Methods inherited from class java.util.logging.Handler

        getEncoding, getErrorManager, getFilter, getFormatter, getLevel, isLoggable, reportError, setEncoding, setErrorManager, setFilter, setFormatter, setLevel
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • RING_SIZE

        public static final int RING_SIZE
        Maximum number of log records retained.
        See Also:
        Constant Field Values
    • Constructor Detail

      • LogHandler

        protected LogHandler()
        Constructor. Invoked lazily by getInstance().
    • Method Detail

      • publish

        public void publish​(java.util.logging.LogRecord record)
        Specified by:
        publish in class java.util.logging.Handler
      • flush

        public void flush()
        Specified by:
        flush in class java.util.logging.Handler
      • close

        public void close()
        Specified by:
        close in class java.util.logging.Handler
      • getRecordColor

        public java.awt.Color getRecordColor​(java.util.logging.LogRecord record)
        Maps log records to display colours.
        Parameters:
        record - log record
        Returns:
        display colour
      • showWindow

        public void showWindow​(java.awt.Component parent)
        Displays a logging window which displays recent (the last 1000) and any future log messages.
        Parameters:
        parent - parent component, may be used for positioning
      • getInstance

        public static LogHandler getInstance()
        Returns the standard instance of this class.
        Returns:
        singleton handler