public class Log
extends Thread
Log file output is flushed automatically after there are no other entries waiting in the internal queue of log entries.
Modifier and Type | Class and Description |
---|---|
class |
Log.Entry
Log entry object. This is used internally for more efficient handling
of log entries on the single internal queue.
|
Modifier and Type | Field and Description |
---|---|
static java.time.format.DateTimeFormatter |
CCYY_MM
Partial date (year and month) used in the construction of log filenames.
|
static int |
ERR
Log.Entry error type (a.k.a., STDERR).
|
static int |
LOG
Log.Entry non-error type (a.k.a., STDOUT).
|
static java.time.format.DateTimeFormatter |
TSTAMP
Full timestamp (date and time with timezone) included in log entries.
|
static String |
VERSION
Version number of this Package (read-only).
|
Constructor and Description |
---|
Log()
Create a Log object that writes its output to STDOUT and STDERR.
|
Log(java.nio.file.Path path)
Create a Log object that writes its output to "${DATE}.log" and its errors
to "${DATE}.err" in the specified path. "CCYY-MM" is the default format
for the ${DATE} variable.
|
Log(java.nio.file.Path path,
String fnOut,
boolean stdout,
String fnErr,
boolean stderr)
Create a Log object.
|
Log(java.nio.file.Path path,
String fnOut,
String fnErr)
Create a Log object.
|
Log(String path)
Create a Log object that writes its output to "${DATE}.log" and its errors
to "${DATE}.err" in the specified path. "CCYY-MM" is the default format
for the ${DATE} variable.
|
Log(String path,
String fnOut,
boolean stdout,
String fnErr,
boolean stderr)
Create a Log object.
|
Log(String path,
String fnOut,
String fnErr)
Create a Log object.
|
Modifier and Type | Method and Description |
---|---|
Log.Entry |
add(String msg)
Add a normal log entry to the internal queue for logged output that is akin
to sending to stdout.
|
Log.Entry |
add(String pre,
String msg)
Add a normal log entry to the internal queue for logged output that is akin
to sending to stdout.
|
Log.Entry |
err(String msg)
Add an error log entry to the internal queue for logged output that is akin
to sending to stderr.
|
Log.Entry |
err(String pre,
String msg)
Add an error log entry to the internal queue for logged output that is akin
to sending to stderr.
|
void |
run()
Background task.
|
String |
toString()
Provide debug-readable output version of this object.
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, yield
public static final java.time.format.DateTimeFormatter CCYY_MM
public static final int ERR
public static final int LOG
public static final java.time.format.DateTimeFormatter TSTAMP
public static final String VERSION
public Log()
public Log(java.nio.file.Path path)
path
- Path where log files are to be createdpublic Log(java.nio.file.Path path, String fnOut, boolean stdout, String fnErr, boolean stderr)
path
- Path where log files are to be created and written tofnOut
- Base query log filename (before the ".CCYY-MM.log" portion)stdout
- Output to STDOUT in tandem with log file output (overrides to
TRUE if fnOut is NULL)fnErr
- Base error log filename (before the ".CCYY-MM.log" portion)stderr
- Output to STDERR in tandem with err file output (overrides to
TRUE if fnErr is NULL)public Log(java.nio.file.Path path, String fnOut, String fnErr)
path
- Path where log files are to be created and written tofnOut
- Base query log filename (before the ".CCYY-MM.log" portion)fnErr
- Base error log filename (before the ".CCYY-MM.log" portion)public Log(String path)
path
- Path where log files are to be createdpublic Log(String path, String fnOut, boolean stdout, String fnErr, boolean stderr)
path
- Path where log files are to be created and written tofnOut
- Base query log filename (before the ".CCYY-MM.log" portion)stdout
- Output to STDOUT in tandem with log file output (overrides to
TRUE if fnOut is NULL)fnErr
- Base error log filename (before the ".CCYY-MM.log" portion)stderr
- Output to STDERR in tandem with err file output (overrides to
TRUE if fnErr is NULL)public Log(String path, String fnOut, String fnErr)
path
- Path where log files are to be created and written tofnOut
- Base query log filename (before the ".CCYY-MM.log" portion)fnErr
- Base error log filename (before the ".CCYY-MM.log" portion)public Log.Entry add(String msg)
msg
- Log message (the portion after the timestamp)public Log.Entry add(String pre, String msg)
pre
- Log pre-amble (the portion before the timestamp)msg
- Log message (the portion after the timestamp)public Log.Entry err(String msg)
msg
- Log message (the portion after the timestamp)public Log.Entry err(String pre, String msg)
pre
- Log pre-amble (the portion before the timestamp)msg
- Log message (the portion after the timestamp)public void run()
run
in interface Runnable
run
in class Thread
public String toString()
toString
in class Thread