Logger

public class Logger

A utility class for logging errors. Only has a single instance, which by default sends messages to System.err. A different target may be provided using open(String) or open(OutputStream).

Author:Tim

Methods

close

public void close()

Closes the currently opened file or stream and reverts to logging to System.err.

getInstance

public static Logger getInstance()

open

public boolean open(String filename)

Attempts to redirect messages to a file.

Parameters:
  • filename
    • the name of the file in which to store messages
Returns:

whether the file was successfully opened

open

public boolean open(OutputStream stream)

Attempts to redirect messages to an output stream.

Parameters:
  • stream
    • the name of the stream to which to send messages
Returns:

whether the stream was successfully opened

recordMessage

public void recordMessage(String message, MessageLevel level)

Records a message to the currently opened stream or file.

Parameters:
  • message
  • level
    • the level of urgency of the message