Class SimpleLogFormatter

java.lang.Object
java.util.logging.Formatter
gov.usgs.util.logging.SimpleLogFormatter

public class SimpleLogFormatter extends Formatter
Simple(r) log formatter for java.util.logging messages. Outputs unique dates once, with all messages sharing that time tab indented below. Example Format:
 Wed Sep 30 19:31:48 GMT 2009
 INFO    Exit code=0
 Wed Sep 30 19:32:52 GMT 2009
 INFO    [polldir] duplicate product id=urn:earthquake-usgs-gov:shakemap-scraper:global:2009medd:1
 Wed Sep 30 19:32:53 GMT 2009
 INFO    [polldir] received urn:earthquake-usgs-gov:shakemap-scraper:global:2009medd:1
 INFO    [losspager] filtering type 'shakemap-scraper', not allowed
 INFO    [logging_client] received urn:earthquake-usgs-gov:shakemap-scraper:global:2009medd:1
 INFO    [shakemap] received urn:earthquake-usgs-gov:shakemap-scraper:global:2009medd:1
 
  • Field Details

    • MILLIS_PER_SECOND

      public static final long MILLIS_PER_SECOND
      Milliseconds in a second.
      See Also:
  • Constructor Details

    • SimpleLogFormatter

      public SimpleLogFormatter()
      Default constructor.
    • SimpleLogFormatter

      public SimpleLogFormatter(boolean timestampsEnabled)
      Constructor with log timestamp option.
      Parameters:
      timestampsEnabled - flag indicating if timestamps are included or not
  • Method Details

    • format

      public final String format(LogRecord record)
      Format a LogRecord for output.
      Specified by:
      format in class Formatter
      Parameters:
      record - LogRecord to format.
      Returns:
      formatted LogRecord as String.
    • getTimestampsEnabled

      public Boolean getTimestampsEnabled()
      Check if time stamps are currently enabled.
      Returns:
      flag indicating if timestamps are currently enabled
    • setTimestampsEnabled

      public void setTimestampsEnabled(Boolean timestampsEnabled)
      Set if timestamps are currently enabled.
      Parameters:
      timestampsEnabled - True to enable timestamps, false otherwise.