Class Log
java.lang.Object
edu.uky.cs.nil.tt.Log
- All Implemented Interfaces:
AutoCloseable
A log is used to record system messages and session data.
A server log has two basic functions:
- Write system message to standard output and (optionally) a file.
- Record completed storytelling
sessions, each in its own file in a directory.
- Author:
- Stephen G. Ware
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGenerates arandom nameand writes the details of a completed storytellingsessionto a file with that name in the session file directory (if session are being recorded).voidWrites a system message tostandard outputand to the log file (if a log file is being used).static voidWrites a system message tostandard outputand to the given server log, if it exists.voidWrites a system message and the details of athrowabletostandard error outputand to the log file (if a log file is being used)static voidWrites a system message and the details of athrowabletostandard error outputand to the given server log, if it exists.voidclose()
-
Constructor Details
-
Log
Constructs a new server log.- Parameters:
log- the file to which system message will be written, or null if system message should only be written to standard outputsessions- the directory to which completed session files should be written, or null if sessions should not be recorded- Throws:
IOException- if a problem occurs when creating or opening the log file or session directory
-
-
Method Details
-
append
Writes a system message tostandard outputand to the given server log, if it exists.- Parameters:
message- the message to writelog- the server log to which the message will be written, or null if the message should only be written to standard output
-
append
Writes a system message and the details of athrowabletostandard error outputand to the given server log, if it exists.- Parameters:
message- the message explaining the context of the throwablethrowable- the throwable whose details and stack trace will be writtenlog- the server log to which the message and details will be written, or null if they should only be written to standard error output
-
append
Writes a system message tostandard outputand to the log file (if a log file is being used).- Parameters:
message- the message to write
-
append
Writes a system message and the details of athrowabletostandard error outputand to the log file (if a log file is being used)- Parameters:
message- the message that gives context for the throwablethrowable- the throwable whose details and stack trace will be written
-
append
Generates arandom nameand writes the details of a completed storytellingsessionto a file with that name in the session file directory (if session are being recorded). If sessions are not being recorded, this method does nothing and returns null.- Parameters:
session- a completed session- Returns:
- the randomly generated session name
- Throws:
IOException- if a problem occurs while writing the session to file
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
IOException
-