public class LogStream
extends java.io.PrintStream
LogStream log = LogStream.getInstance(); if (log.level >= 2) { log.println("SomeIdentifier: If the level is 2 or above, this message will be logged."); }
Messages should be prefixed with an identifier followed immediately by a colon. Alternative LogStream implementaitons can use this identifier as a selector. This convention is not required but it is used throughout the Jespa codebase (with the exception of stack traces because they span multiple lines).
Log level values are described in the following table. The default log level is 1 to indicate only critical information should be logged.
To redirect logging in Jespa to an alternative logging solution (such as java.util.logging), use setInstance(java.io.PrintStream)
to install an implementation of PrintStream.
Level | Description |
---|---|
0 | Nothing. |
1 | Log critical information only. The is the default level value. |
2 | Basic information that can be logged under load. |
3 | More detailed information that should not significantly effect application performace but should only be used intermittently as it could result in excessive log entries. |
4+ | Level 4 and higher should be used for debugging purposes only. |
Modifier and Type | Field and Description |
---|---|
static int |
level
The level of information to log.
|
Constructor and Description |
---|
LogStream(java.io.OutputStream out) |
Modifier and Type | Method and Description |
---|---|
static LogStream |
getInstance()
Get the shared static log stream instance.
|
void |
println(java.lang.Object o) |
void |
println(java.lang.String s) |
static void |
setInstance(java.io.PrintStream stream)
Set the shared static stream that should be used throughout the Jespa library.
|
static void |
setLevel(int level)
Set the level of information that should be logged.
|
java.lang.String |
toString() |
append, append, append, checkError, clearError, close, flush, format, format, print, print, print, print, print, print, print, print, print, printf, printf, println, println, println, println, println, println, println, println, setError, write, write
public static int level
setLevel(int)
public static void setLevel(int level)
level
public static void setInstance(java.io.PrintStream stream)
To control where data is written, supply an instance of PrintStream with a write(byte[]) method that writes the log message to the desired sink. This class's default implementations of println will call write(byte[]) with each log message and a platform appropritate line break.
To modify the content of each log message, the stream parameter should be an instance of LogStream that overrides the println(String) and println(Object) methods to modify the message as necessary and then call the super method with the same signature (or write(byte[]) could be called directly).
public static LogStream getInstance()
setInstance(java.io.PrintStream)
, the default LogStream is one
created with the System.err stream.public void println(java.lang.Object o)
println
in class java.io.PrintStream
public void println(java.lang.String s)
println
in class java.io.PrintStream
public java.lang.String toString()
toString
in class java.lang.Object