SK.gnome.dwarf.log
Class Log

java.lang.Object
  extended bySK.gnome.dwarf.log.Log

public final class Log
extends java.lang.Object

Globally controls generating of logging messages.

Each application consists of logical parts which we will call here the application subsystems. A graphical user interface can be the application subsystem as well as a monitoring agent, for example. Let's say that we identify these two subsystems by two string constants - "gui" and "monitor". The Log static class provides a way how to enable or disable generating of debugging messages (i.e. messages with the LOG_DEBUG level) as well as the tracing messages (messages with the LOG_TRACE level) for the particular application subsystems, identified by these string constants.

By disabling the log messages you can save the system resources as well as speed-up the overall application performance. On the other hand, enabling them gives you a more detailed information about the activity of the particular application subsystem.

The setDebug(String) and getDebug(String) static methods can be used to enable or disable generating of debugging messages for an application subsystem. Therefore the setDebug method accepts a space-separated list of strings, identifying the particular subsystems.

A sample use of the setDebug(String) and getDebug(String) methods:

 // enable debugging messages for generic TCP/IP services and SMTP server:
 Log.setDebug("tcpip, smtp");

 // this message WILL be generated:
 if (Log.getDebug("smtp"))
   log(LOG_DEBUG, "SMTP ready to serve.));

 // this message WILL NOT be generated:
 if (Log.getDebug("http"))
   log(LOG_DEBUG, "HTTP ready to serve, too.));

 // disable generating of any debugging messages:
 Log.setDebug("");

 // this message WILL NOT be generated:
 if (Log.getDebug("snmp"))
   log(LOG_DEBUG, "SNMP ready to serve hopefully.));
 

The setTrace(String) and getTrace(String) methods work analogically for the log messages with the Service.LOG_TRACE logging level.

The following subsystem identifiers are reserved by the core Dwarf framework and can be controlled via this class:

By passing one of these identifiers to the setDebug(String) or setTrace(String) method you can increase the global verbosity of the log messages generated by the application.

Other Dwarf-based applications may use their own subsystem identifiers, as "http" for the Dwarf HTTP Server, for example.


Method Summary
static java.util.Set getDebug()
          Returns the subsystem identifiers for the debugging messages.
static boolean getDebug(java.lang.String id)
          Whether the debugging messages are enabled for the given subsystem identifier.
static java.util.Set getTrace()
          Returns the subsystem identifiers for the tracing messages.
static boolean getTrace(java.lang.String id)
          Whether the tracing messages are enabled for the given subsystem identifier.
static void setDebug(java.lang.String identifiers)
          Enables debugging messages for the given subsystem identifiers.
static void setTrace(java.lang.String identifiers)
          Enables tracing messages for the given subsystem identifiers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getDebug

public static java.util.Set getDebug()
Returns the subsystem identifiers for the debugging messages.

It returns the set of string subsystem identifiers for which the debugging messages are currently enabled.

Returns:
unmodifiable set of identifiers
See Also:
setDebug(String)

getDebug

public static boolean getDebug(java.lang.String id)
Whether the debugging messages are enabled for the given subsystem identifier.

Parameters:
id - the subsystem identifier
Returns:
true if the debugging messages are enabled
See Also:
setDebug(String)

setDebug

public static void setDebug(java.lang.String identifiers)
Enables debugging messages for the given subsystem identifiers.

A comma-separated list of string constants identifying the particular application subsystems should be used as an argument.

If a security manager is installed, the ServicePermission "setDebug" is checked first.

Parameters:
identifiers - the subsystem identifiers
See Also:
getDebug(), getDebug(String)

getTrace

public static java.util.Set getTrace()
Returns the subsystem identifiers for the tracing messages.

It returns the set of string subsystem identifiers for which the tracing messages are currently enabled.

Returns:
unmodifiable set of indentifiers
See Also:
setTrace(String)

getTrace

public static boolean getTrace(java.lang.String id)
Whether the tracing messages are enabled for the given subsystem identifier.

Parameters:
id - the subsystem identifier
Returns:
true if the tracing messages are enabled
See Also:
setTrace(String)

setTrace

public static void setTrace(java.lang.String identifiers)
Enables tracing messages for the given subsystem identifiers.

A comma-separated list of string constants identifying the particular application subsystems should be used as an argument.

If a security manager is installed, the ServicePermission "setTrace" is checked first.

Parameters:
identifiers - the subsystem identifiers
See Also:
getTrace(), getTrace(String)


Copyright (c) 1999-2005, Gnome Ltd. All rights reserved.