net.juniper.smgt.lib.logging
Class LogWriter
java.lang.Object
net.juniper.smgt.lib.logging.LogEventBase
net.juniper.smgt.lib.logging.LogWriter
- All Implemented Interfaces:
- net.juniper.smgt.lib.logging.LogEventSource, net.juniper.smgt.lib.logging.LogWriterI
public class LogWriter
- extends net.juniper.smgt.lib.logging.LogEventBase
- implements net.juniper.smgt.lib.logging.LogWriterI
This class prints messages to a log.
Simply create a LogWriter with one of the static getLogWriter()
methods and then use println(message) to log message.
Many modules initialize multiple LogWriters for different
loglevels.
Optionally use the isActive() method to check if the LogWriter
has listeners attached before composing long messages.
Example:
LogWriter err = LogWriter.getLogWriter("test", Logger.ERROR);
LogWriter log = LogWriter.getLogWriter("test", Logger.INFO);
LogWriter debug = LogWriter.getLogWriter("test", Logger.DEBUG);
log.println("Will test logging");
if (debug.isActive())
debug.println("This String" + "is only generated" +
"if there is someone to listen");
Methods inherited from class net.juniper.smgt.lib.logging.LogEventBase |
addLogEventListener, isActive, removeLogEventListener, sendEvent |
getLogWriter
public static LogWriter getLogWriter(String gr,
byte prio)
- Use this static method to get a new LogWriter for a specified
group and priority.
- Parameters:
gr
- the group that this LogWriter's messages will belong toprio
- the priority of this LogWriter's messages
- Returns:
- new LogWriter instance
println
public void println(String str)
- Append the string to the Buffer and then flush the whole Buffer
as a single string to the log.
- Specified by:
println
in interface net.juniper.smgt.lib.logging.LogWriterI
println
public void println(String str,
Throwable x)
- Specified by:
println
in interface net.juniper.smgt.lib.logging.LogWriterI