Class XRSimpleLogFormatter


  • public class XRSimpleLogFormatter
    extends java.util.logging.Formatter
    A java.util.logging.Formatter class that writes a bare-bones log messages, with no origin class name and no date/time.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.lang.String EX_MSG_FMT  
      private java.text.MessageFormat exmformat
      MessageFormat for messages with a throwable
      private java.text.MessageFormat mformat
      MessageFormat for standard messages (without Throwable)
      private static java.lang.String MSG_FMT  
      private boolean[] usedPlaceholderForExmsgFmt  
      private boolean[] usedPlaceholderForMsgFmt  
    • Constructor Summary

      Constructors 
      Constructor Description
      XRSimpleLogFormatter()  
      XRSimpleLogFormatter​(java.lang.String msgFmt, java.lang.String throwableMsgFmt)
      Create a custom log formatter for use with: JDKXRLogger(boolean, Level, Handler, Formatter) Options: {0} String.valueOf(record.getMillis()), {1} record.getLoggerName(), {2} record.getLevel().toString(), {3} record.getSourceClassName(), {4} record.getSourceMethodName(), {5} record.getMessage() {6} record.getThrown().getName() {7} record.getThrown().getMessage() {8} record.getThrown() stack trace Example (msgFmt): {1} {2}:: {5}\n

      Example (throwableMsgFmt): {1} {2}:: {5} => {6}:: {7}\n
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String format​(java.util.logging.LogRecord record)
      Format the given log record and return the formatted string.
      java.lang.String formatMessage​(java.util.logging.LogRecord record)
      Localize and format the message string from a log record.
      java.lang.String getHead​(java.util.logging.Handler h)
      Return the header string for a set of formatted records.
      java.lang.String getTail​(java.util.logging.Handler h)
      Return the tail string for a set of formatted records.
      private static boolean[] usedPlaceholder​(java.text.MessageFormat messageFormat)
      Identify which arguments are effectively used.
      • Methods inherited from class java.lang.Object

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

      • mformat

        private final java.text.MessageFormat mformat
        MessageFormat for standard messages (without Throwable)
      • exmformat

        private final java.text.MessageFormat exmformat
        MessageFormat for messages with a throwable
      • usedPlaceholderForMsgFmt

        private final boolean[] usedPlaceholderForMsgFmt
      • usedPlaceholderForExmsgFmt

        private final boolean[] usedPlaceholderForExmsgFmt
    • Constructor Detail

      • XRSimpleLogFormatter

        public XRSimpleLogFormatter()
      • XRSimpleLogFormatter

        public XRSimpleLogFormatter​(java.lang.String msgFmt,
                                    java.lang.String throwableMsgFmt)
        Create a custom log formatter for use with: JDKXRLogger(boolean, Level, Handler, Formatter) Options:
        • {0} String.valueOf(record.getMillis()),
        • {1} record.getLoggerName(),
        • {2} record.getLevel().toString(),
        • {3} record.getSourceClassName(),
        • {4} record.getSourceMethodName(),
        • {5} record.getMessage()
        • {6} record.getThrown().getName()
        • {7} record.getThrown().getMessage()
        • {8} record.getThrown() stack trace
        Example (msgFmt): {1} {2}:: {5}\n

        Example (throwableMsgFmt): {1} {2}:: {5} => {6}:: {7}\n
    • Method Detail

      • usedPlaceholder

        private static boolean[] usedPlaceholder​(java.text.MessageFormat messageFormat)
        Identify which arguments are effectively used.
      • format

        public java.lang.String format​(java.util.logging.LogRecord record)
        Format the given log record and return the formatted string.
        Specified by:
        format in class java.util.logging.Formatter
      • formatMessage

        public java.lang.String formatMessage​(java.util.logging.LogRecord record)
        Localize and format the message string from a log record.
        Overrides:
        formatMessage in class java.util.logging.Formatter
      • getHead

        public java.lang.String getHead​(java.util.logging.Handler h)
        Return the header string for a set of formatted records.
        Overrides:
        getHead in class java.util.logging.Formatter
      • getTail

        public java.lang.String getTail​(java.util.logging.Handler h)
        Return the tail string for a set of formatted records.
        Overrides:
        getTail in class java.util.logging.Formatter