java.lang.Object
net.i2p.addressbook.Log

class Logextends Object
A simple log with automatic time stamping.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final Pattern
    Matches the date at the start of a log line.
    private final File
    The log file being written.
    private static final int
    Lines kept before the oldest are dropped.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Log(File file)
    Construct a Log instance that writes to the File file.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    append(String entry)
    Write entry to a new line in the log, with appropriate time stamp.
    private String
    Turns one raw line into a displayable entry.
    private void
    Drops the oldest lines once the log grows too long.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • MAX_LINES

      private static final int MAX_LINES
      Lines kept before the oldest are dropped.
      See Also:
    • DATE_PATTERN

      private static final Pattern DATE_PATTERN
      Matches the date at the start of a log line.
    • file

      private final File file
      The log file being written.
  • Constructor Details

    • Log

      public Log(File file)
      Construct a Log instance that writes to the File file.
      Parameters:
      file - A File for the log to write to.
  • Method Details

    • append

      public void append(String entry)
      Write entry to a new line in the log, with appropriate time stamp.
      Parameters:
      entry - A String containing a message to append to the log.
    • trimLog

      private void trimLog()
      Drops the oldest lines once the log grows too long.
    • fixEntry

      private String fixEntry(String line)
      Turns one raw line into a displayable entry.
      Parameters:
      line - the line as stored
      Returns:
      the line to show