Package ch.k43.util

Klasse KLogJSONFormatter

java.lang.Object
java.util.logging.Formatter
ch.k43.util.KLogJSONFormatter

public class KLogJSONFormatter extends Formatter
Format logging output as JSON formatted string with UUID, time stamp, logging level, code location and the logging information. The KLog.debug(), KLog.info() and KLog.error() adds the code location, delimited by KLog.DELIMITER which is then formatted here.
 Example:
 KLog.info("Program start");
 
 Output:
 {
   "KLog": [
     {
       "UUID": "dd5ff181-34bb-4f34-982d-65c8b4a0f264",
       "Logtime": "2024-06-21T18:32:54.958",
       "Level": "Information",
       "Location": "main[1]:Test:main:21",
       "Text": "Program start"
     }
   ]
 }
 
  • Konstruktordetails

    • KLogJSONFormatter

      public KLogJSONFormatter()
      Class constructor.
  • Methodendetails

    • format

      public String format(LogRecord argRecord)
      Format the log message
      Angegeben von:
      format in Klasse Formatter
    • getHead

      public String getHead(Handler argHandler)
      Set header.
      Setzt außer Kraft:
      getHead in Klasse Formatter
    • getTail

      public String getTail(Handler argHandler)
      Set JSON footer. Note: Due to a bug in the JVM, the getTail() is not called by the ConsoleHandler.
      Setzt außer Kraft:
      getTail in Klasse Formatter
    • toString

      public String toString()
      String representation of object.
      Setzt außer Kraft:
      toString in Klasse Object
      Seit:
      2024.08.23