org.jcoderz.phoenix.checkstyle
Class LoggingLevel
java.lang.Object
com.puppycrawl.tools.checkstyle.api.AutomaticBean
com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
com.puppycrawl.tools.checkstyle.api.Check
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:
- LoggerName = logger
- AllowedLoggerMethods
= fine,finer,entering,exiting,throwing,finest
- LogCallMaxLevel = FINE
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.
| 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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LoggingLevel
public LoggingLevel()
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.