net.i2p.util

## Class LogWriter

- java.lang.Object
- - net.i2p.util.LogWriter

- All Implemented Interfaces:
    Runnable
  Direct Known Subclasses:
    FileLogWriter

      abstract class LogWriter
      extends Object
      implements Runnable

  Log writer thread that pulls log records from the LogManager and writes them to the log. This also periodically instructs the LogManager to reread its config file.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected LogManager` | `_manager`
    `protected boolean` | `_write`
    `(package private) static long` | `FLUSH_INTERVAL`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `LogWriter(LogManager manager)`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract void` | `closeWriter()`
    `abstract String` | `currentFile()` File may not exist or have old logs in it if not opened yet
    `void` | `flushRecords()`
    `void` | `flushRecords(boolean shouldWait)`
    `protected abstract void` | `flushWriter()`
    `void` | `run()`
    `void` | `setFlushInterval(long interval)` Set the flush interval for the log writer.
    `void` | `stopWriting()`
    `protected abstract void` | `writeRecord(int priority, String line)` Write a single String verbatim to the writer.
    `protected abstract void` | `writeRecord(LogRecord rec, String formatted)` Write the provided LogRecord to the writer.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### _manager

          protected final LogManager _manager

    - #### _write

          protected volatile boolean _write

    - #### FLUSH_INTERVAL

          static final long FLUSH_INTERVAL

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### LogWriter

          public LogWriter(LogManager manager)

  - ### Method Detail

    - #### closeWriter

          protected abstract void closeWriter()

    - #### currentFile

          public abstract String currentFile()

      File may not exist or have old logs in it if not opened yet
      Returns:
        non-null

    - #### flushRecords

          public void flushRecords()

    - #### flushRecords

          public void flushRecords(boolean shouldWait)

    - #### flushWriter

          protected abstract void flushWriter()

    - #### run

          public void run()

      Specified by:
        `run` in interface `Runnable`

    - #### setFlushInterval

          public void setFlushInterval(long interval)

      Set the flush interval for the log writer.
      Parameters:
        `interval` - the interval in milliseconds

    - #### stopWriting

          public void stopWriting()

    - #### writeRecord

          protected abstract void writeRecord(int priority,
                                              String line)

      Write a single String verbatim to the writer.
      Parameters:
        `priority` - the level to log the line at.
        `line` - the String to write.

    - #### writeRecord

          protected abstract void writeRecord(LogRecord rec,
                                              String formatted)

      Write the provided LogRecord to the writer.
      Parameters:
        `rec` - the LogRecord to write.
        `formatted` - a String pre-formatted from rec, may be ignored.