public class ErrorLog extends PrintStream implements Runnable
System.err
and
System.out
to print out errors both to the console (terminal) as well
as to a log file in the OS specific temporary directory.T-Plan Robot Enterprise, (C) 2009-2022 T-Plan Limited. All rights reserved.
Modifier and Type | Field and Description |
---|---|
static String |
CFG_LOG_DIR |
Modifier and Type | Method and Description |
---|---|
static void |
addErrListener(PropertyChangeListener l)
Add a listener to the System.err stream.
|
static void |
addOutListener(PropertyChangeListener l)
Add a listener to the System.out stream.
|
static void |
close(boolean deleteLogFile,
boolean printHeader) |
static void |
dumpNow()
Dump all thread stack traces to the error output.
|
static File |
getCurrentLogFile() |
static File |
getDefaultLogDir() |
static File |
getLogDirectory() |
static LinkedHashMap<Long,File> |
getLogFiles() |
static PrintStream |
install() |
boolean |
isEnabled()
Find out if the log is enabled.
|
static boolean |
isOS64Bit() |
static void |
relocate(String path) |
static void |
removeErrListener(PropertyChangeListener l)
Remove a listener from the System.err stream.
|
static void |
removeOutListener(PropertyChangeListener l)
Remove a listener from the System.out stream.
|
void |
run() |
static void |
scheduleDump(int time,
boolean repeats)
Schedule an application dump to write all thread stack traces into the
console and the log file.
|
static void |
scheduleDump(int time,
boolean repeats,
File heapDumpFile)
Schedule an application dump to write all thread stack traces into the
console and the log file and optionally also a heap dump.
|
static void |
setDiscardLog(boolean aDiscardLog)
Set the flag indicating whether the log should be discarded and its file
deleted on exit.
|
void |
setEnabled(boolean enabled)
Enable or disable the log.
|
static void |
shutDown()
Shut down the logger and close the log file.
|
void |
write(byte[] b) |
void |
write(byte[] b,
int off,
int len) |
void |
write(int b) |
public static final String CFG_LOG_DIR
public static void relocate(String path) throws IOException
IOException
public static File getDefaultLogDir()
public void write(int b)
write
in class PrintStream
public void write(byte[] b) throws IOException
write
in class FilterOutputStream
IOException
public void write(byte[] b, int off, int len)
write
in class PrintStream
public static void shutDown()
public static PrintStream install() throws IOException
IOException
public static void close(boolean deleteLogFile, boolean printHeader)
public static void addOutListener(PropertyChangeListener l)
l
- a listener to be notified when a string gets printed out through
System.out.public static void removeOutListener(PropertyChangeListener l)
l
- a listener.public static void addErrListener(PropertyChangeListener l)
l
- a listener to be notified when a string gets printed out through
System.err.public static void removeErrListener(PropertyChangeListener l)
l
- a listener.public static boolean isOS64Bit()
public static File getLogDirectory()
public static File getCurrentLogFile()
public static LinkedHashMap<Long,File> getLogFiles()
public boolean isEnabled()
public void setEnabled(boolean enabled)
enabled
- true to enable or false to disable. The log is by default
enabled.public static void scheduleDump(int time, boolean repeats)
time
- time period.repeats
- true to repeat the dump, false for one time dump.public static void scheduleDump(int time, boolean repeats, File heapDumpFile)
time
- time period.repeats
- true to repeat the dump, false for one time dump.heapDumpFile
- the file to write the heap dump to. When null no heap
dump will be created.public static void dumpNow()
public static void setDiscardLog(boolean aDiscardLog)
aDiscardLog
- true to make the logger discard the log.