|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--Log
A general 'logger' or 'tracer' class that logs data into a file.
public class LogTest {
public LogTest() {
Log.open("c:\project\ErrorStream.log", "err");
Log.open("c:\project\StandardStream.log", "std");
Log.open("c:\prod.output", "out");
this.testLog();
Log.close("err");
Log.close();
}
public void testLog() {
Log.log("err", "This is an error Test.", false);
Log.log("std", "This is a standard test.");
Log.log("This will also output to standard since it was last opened and written to.");
Log.log("out", "This is to output.");
Log.log("Now this will write to the out stream.");
}
}
| Field Summary | |
static java.lang.String |
lastStream
Stores the last open stream for quick logging. |
static java.util.Map |
openFiles
Map of all open streams. |
| Constructor Summary | |
Log()
|
|
| Method Summary | |
static void |
close()
Closes the iostream for a all log files. |
static void |
close(java.lang.String name)
Closes the iostream for a specific log file. |
static boolean |
log(java.lang.Object input)
Lazy man's log method, logs to the last open stream, new line by default. |
static boolean |
log(java.lang.String name,
java.lang.Object input)
Default log method, creates new line for each input. |
static boolean |
log(java.lang.String name,
java.lang.Object input,
boolean nl)
Logs input into file only if it is open. |
static void |
open(java.lang.String file,
java.lang.String name)
Opens a file to write into. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static java.util.Map openFiles
public static java.lang.String lastStream
| Constructor Detail |
public Log()
| Method Detail |
public static void open(java.lang.String file,
java.lang.String name)
file - the actualy path of the file that this log will write to.name - the simple name that this specific log will be referenced by.
public static boolean log(java.lang.String name,
java.lang.Object input,
boolean nl)
name.
name - the name of a file stream to log to.input - the object input to log.nl - whether to write a 'new line' to end of line or not.
public static boolean log(java.lang.String name,
java.lang.Object input)
name.
name - the name of a file stream to log to.input - the object input to log.
public static boolean log(java.lang.Object input)
public static void close()
public static void close(java.lang.String name)
name - the name of the log to close.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||