Package wt.wvs

Class WVSLogger

java.lang.Object
wt.wvs.WVSLogger

public final class WVSLogger extends Object
A wrapper class (encapsulating the Log4j Logger) to help facilitate in acquiring a logger for a specific WVS class adhering to a grouping structure. Instead of using the full class name as the logger name, WVS will use this class to retrieve a logger. This will allow a System Administrator to enable logging for a WVS group. For example, if we have the following classes that are both used to support publishing:
 com.ptc.wvs.server.publish.MyNewClass
 com.ptc.wvs.common.ui.AnotherNewClass
 
And these classes retrieve a logger by doing the following:
 private static final WVSLogger logger =
             WVSLogger.getLogger(MyNewClass.class, WVSLogger.PUBLISH_GROUP);
 private static final WVSLogger logger =
             WVSLogger.getLogger(AnotherNewClass.class, WVSLogger.PUBLISH_GROUP);
 
The actual logger names for these classes will be "wt.wvs.publish.MyNewClass" and "wt.wvs.publish.AnotherNewClass". Both our new classes belong to the publish group. If a System Administrator enables logging for the "wt.wvs.pulish" group, logging contained in both classes will be displayed despite that both classes actually reside in different packages.

The WVSLogger class also contains additional supporting APIs to assist in performing logging functions. The following example illustrates how to use this class to acquire a logger and demonstrates some of the API's used to assist in logging.
 class MyNewClass {

     private static final WVSLogger logger =
             WVSLogger.getLogger(MyNewClass.class, WVSLogger.PUBLISH_GROUP);

     public String performPublishStuff(ConfigSpec configSpec, String template, WTPart part) {

         boolean traceEnabled = logger.isTraceEnabled();
         if (traceEnabled)
                 WVSLogger.traceMethodEntryVars("configSpec,template,part",
                         new Object[]{configSpec, template, part});

         try {
              logger.debug("starting to perform publish stuff");

              // do some work.
              String myReturnVal = "some stuff";
         }
         catch (Exception e) {
              logger.error("An exception occurred when performing publish stuff", e);
         }

         if (traceEnabled)
                 WVSLogger.traceMethodExitVars("myReturnVal"
                         new Object[]{myReturnVal});

         return myReturnVal;
     }
 }
 


Supported API: true

Extendable: false
  • Method Details

    • getLogger

      public static WVSLogger getLogger(String _loggerName)
      Retrieve a WVSLogger with the logger's full name.
      Parameters:
      _loggerName - - logger full name.
      Returns:
      WVSLogger - The WVSLogger of the specified name.

      Supported API: true
    • getLogger

      public static WVSLogger getLogger(String _shortName, String _group)
      Retrieve a WVSLogger with the short name of the logger and the group as the prefix.
      Parameters:
      _shortName - - logger's short name.
      _group - - Group prefix
      Returns:
      WVSLogger - The WVSLogger of the specified group and short name.

      Supported API: true
    • getLogger

      public static WVSLogger getLogger(Class _logClass, String _group)
      Retrieve a WVSLogger with the name of the Class and the group as the prefix.
      Parameters:
      logClass - Class - target class in need of a logger.
      group - String - Group prefix
      Returns:
      WVSLogger - WVSLogger for the target Class.

      Supported API: true
    • getLogger

      public static WVSLogger getLogger(Class _logClass)
      Retrieve WVSLogger for the given Class. We will use this if a particular class doesn't fall into the available groups.
      Parameters:
      logClass - Class - target class in need of a logger.
      Returns:
      WVSLogger - WVSLogger for the target Class.

      Supported API: true
    • debug

      public void debug(Object message)


      Supported API: true
    • error

      public void error(Object message)


      Supported API: true
    • isDebugEnabled

      public boolean isDebugEnabled()


      Supported API: true