Package uk.ac.starlink.topcat

# Class LogHandler

java.lang.Object
java.util.logging.Handler
uk.ac.starlink.topcat.LogHandler

public class LogHandler extends Handler
Log handler which can provide a window displaying recent log events.

Since:
  5 Aug 2021
Author:
  Mark Taylor (Starlink)

## Field Summary

Fields
Modifier and Type
Field
Description
`static final int`
`RING_SIZE`
Maximum number of log records retained.

## Constructor Summary

Constructors
Modifier
Constructor
Description
`protected`
`LogHandler()`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`void`
`close()`
`void`
`flush()`
`static LogHandler`
`getInstance()`
Returns the standard instance of this class.
`Color`
`getRecordColor(LogRecord record)`
Maps log records to display colours.
`void`
`publish(LogRecord record)`
`void`
`showWindow(Component parent)`
Displays a logging window which displays recent (the last 1000) and any future log messages.

### Methods inherited from class java.util.logging.Handler

`getEncoding, getErrorManager, getFilter, getFormatter, getLevel, isLoggable, reportError, setEncoding, setErrorManager, setFilter, setFormatter, setLevel`

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

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

## Field Details

### RING_SIZE

public static final int RING_SIZE
Maximum number of log records retained.

See Also:
  - Constant Field Values

## Constructor Details

### LogHandler

protected LogHandler()
Constructor. Invoked lazily by `getInstance()`.

## Method Details

### publish

public void publish(LogRecord record)

Specified by:
  `publish` in class `Handler`

### flush

public void flush()

Specified by:
  `flush` in class `Handler`

### close

public void close()

Specified by:
  `close` in class `Handler`

### getRecordColor

public Color getRecordColor(LogRecord record)
Maps log records to display colours.

Parameters:
  `record` - log record
Returns:
  display colour

### showWindow

public void showWindow(Component parent)
Displays a logging window which displays recent (the last 1000) and any future log messages.

Parameters:
  `parent` - parent component, may be used for positioning

### getInstance

public static LogHandler getInstance()
Returns the standard instance of this class.

Returns:
  singleton handler