Core API 7.8

net.juniper.smgt.lib.logging
Class LogWriter

java.lang.Object
  extended by net.juniper.smgt.lib.logging.LogEventBase
      extended by 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");
 


Method Summary
static LogWriter getLogWriter(java.lang.String gr, byte prio)
          Use this static method to get a new LogWriter for a specified group and priority.
 void println(java.lang.String str)
          Append the string to the Buffer and then flush the whole Buffer as a single string to the log.
 void println(java.lang.String str, java.lang.Throwable x)
           
 
Methods inherited from class net.juniper.smgt.lib.logging.LogEventBase
addLogEventListener, isActive, removeLogEventListener, sendEvent
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getLogWriter

public static LogWriter getLogWriter(java.lang.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 to
prio - the priority of this LogWriter's messages
Returns:
new LogWriter instance

println

public void println(java.lang.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(java.lang.String str,
                    java.lang.Throwable x)
Specified by:
println in interface net.juniper.smgt.lib.logging.LogWriterI

Core API 7.8