org.jcoderz.phoenix.checkstyle
Class LoggingLevel

java.lang.Object
  extended by com.puppycrawl.tools.checkstyle.api.AutomaticBean
      extended by com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
          extended by com.puppycrawl.tools.checkstyle.api.Check
              extended by org.jcoderz.phoenix.checkstyle.LoggingLevel
All Implemented Interfaces:
Configurable, Contextualizable

public class LoggingLevel
extends Check

This check makes sure that a class' source code does not contain illegal logging levels in calls to the Java Logging API. Such a check is interesting when you have a logging message framework that uses generated classes for messages up to a certain level in order to guarantee certain information in these messages when written to the log file. One example scenario is when log file entries should be sent to a management console where an operator is looking at the messages and needs to take actions depending on the severity of the information he receives. In such cases it is important that these logging messages need a special format to contain all the necessary information. In our special case an XML was used from which exception or warning message classes had been created. Those classes had to be used for all log levels INFO and above as these logging records were automatically forwarded to the operators sitting in from of a management console, monitoring the application behaviour. For debugging purposes the developer was allowed to use only the logging levels below INFO so that no debugging message accidentally was sent to the management console. The default configuration of this check is:

The class' logger instance variable must have the name 'logger'. Only calls to the methods 'fine', 'finer', 'entering', 'exiting', 'throwing', and 'finest' are allowed. For the methods 'log', 'logp', and 'logrb' only the logging level FINE and below is allowed. You can override these settings by specifying the properties in the checkstyle configuration file.


Constructor Summary
LoggingLevel()
           
 
Method Summary
 int[] getDefaultTokens()
          
 void setAllowedLoggerMethods(String allowedLoggerMethods)
          Sets the names of allowed logger methods.
 void setLogCallMaxLevel(String logCallMaxLevel)
          Sets the maximum allowed level for logger methods starting with 'log' (log, logp, logrb).
 void setLoggerName(String loggerName)
          Sets the name of the logger instance.
 void visitToken(DetailAST ast)
          
 
Methods inherited from class com.puppycrawl.tools.checkstyle.api.Check
beginTree, destroy, finishTree, getAcceptableTokens, getClassLoader, getFileContents, getLines, getRequiredTokens, getTabWidth, getTokenNames, init, leaveToken, log, log, setClassLoader, setFileContents, setMessages, setTabWidth, setTokens
 
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
getId, getMessageBundle, getSeverity, getSeverityLevel, log, log, log, log, log, log, log, log, log, setId, setSeverity
 
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean
configure, contextualize, finishLocalSetup, getConfiguration, setupChild
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LoggingLevel

public LoggingLevel()
Method Detail

setLoggerName

public void setLoggerName(String loggerName)
Sets the name of the logger instance. The default name is 'logger'.

Parameters:
loggerName - The name of the logger.

setAllowedLoggerMethods

public void setAllowedLoggerMethods(String allowedLoggerMethods)
Sets the names of allowed logger methods. The default names are: 'entering', 'exiting', 'throwing', 'fine', 'finer', and 'finest'.

Parameters:
allowedLoggerMethods - The names of allowed logger methods, separated by colons.

setLogCallMaxLevel

public void setLogCallMaxLevel(String logCallMaxLevel)
Sets the maximum allowed level for logger methods starting with 'log' (log, logp, logrb). The default level is 'FINE'.

Parameters:
logCallMaxLevel - The maximum allowed logger level for the methods log, logp, and logrb.

getDefaultTokens

public int[] getDefaultTokens()

Specified by:
getDefaultTokens in class Check

visitToken

public void visitToken(DetailAST ast)

Overrides:
visitToken in class Check


Copyright 2007 The jCoderZ Project.