mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Emmanuel Lecharny (JIRA)" <j...@apache.org>
Subject [jira] Assigned: (DIRMINA-656) Methods log in LoggingFilter.java use the subsequent eventLevel instead of current
Date Mon, 12 Jan 2009 22:08:01 GMT

     [ https://issues.apache.org/jira/browse/DIRMINA-656?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Emmanuel Lecharny reassigned DIRMINA-656:
-----------------------------------------

    Assignee: Emmanuel Lecharny

> Methods log in LoggingFilter.java use the subsequent eventLevel instead of current
> ----------------------------------------------------------------------------------
>
>                 Key: DIRMINA-656
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-656
>             Project: MINA
>          Issue Type: Bug
>          Components: Filter
>    Affects Versions: 2.0.0-M4
>         Environment: Windows-XP SP3
> jdk1.6.0_11
>            Reporter: Aris Marsopoulos
>            Assignee: Emmanuel Lecharny
>            Priority: Minor
>   Original Estimate: 0.08h
>  Remaining Estimate: 0.08h
>
> The log methods in class LoggingFilter use the subsequent eventLevel instead of current
> For example:
> If the current eventLevel i= LogLevel.INFO the log method uses logger.warn to print the
message (see source code for proof).
>     private void log(LogLevel eventLevel, String message) {
>     	if (eventLevel == LogLevel.TRACE) {
>     		logger.trace(message);
>     	} else if (eventLevel.getLevel() > LogLevel.INFO.getLevel()) {
>     		logger.info(message);
>     	} else if (eventLevel.getLevel() > LogLevel.WARN.getLevel()) {
>     		logger.warn(message);
>     	} else if (eventLevel.getLevel() > LogLevel.ERROR.getLevel()) {
>     		logger.error(message);
>     	}
>     }
> Remedy:
> Either replace the > operator by a >= operator in all three log methods or use
a switch statement (see code below)
>     /**
>      * Log if the logger and the current event log level are compatible. We log
>      * a message and an exception.
>      * 
>      * @param eventLevel the event log level as requested by the user
>      * @param message the message to log
>      * @param cause the exception cause to log
>      */
>     private void log(LogLevel eventLevel, String message, Throwable cause) {
>         switch(eventLevel)
>         {
>             case TRACE:
>                 logger.trace(message, cause);
>                 break;
>             case DEBUG:
>             case INFO:
>                 logger.info(message, cause);
>                 break;
>             case WARN:
>                 logger.warn(message, cause);
>                 break;
>             case ERROR:
>                 logger.error(message, cause);
>                 break;
>         }
>     }
>     /**
>      * Log if the logger and the current event log level are compatible. We log
>      * a formated message and its parameters. 
>      * 
>      * @param eventLevel the event log level as requested by the user
>      * @param message the formated message to log
>      * @param param the parameter injected into the message
>      */
>     private void log(LogLevel eventLevel, String message, Object param) {
>         switch(eventLevel)
>         {
>             case TRACE:
>                 logger.trace(message, param);
>                 break;
>             case DEBUG:
>             case INFO:
>                 logger.info(message, param);
>                 break;
>             case WARN:
>                 logger.warn(message, param);
>                 break;
>             case ERROR:
>                 logger.error(message, param);
>                 break;
>         }
>     }
>     /**
>      * Log if the logger and the current event log level are compatible. We log
>      * a simple message. 
>      * 
>      * @param eventLevel the event log level as requested by the user
>      * @param message the message to log
>      */
>     private void log(LogLevel eventLevel, String message) {
>         switch(eventLevel)
>         {
>             case TRACE:
>                 logger.trace(message);
>                 break;
>             case DEBUG:
>             case INFO:
>                 logger.info(message);
>                 break;
>             case WARN:
>                 logger.warn(message);
>                 break;
>             case ERROR:
>                 logger.error(message);
>                 break;
>         }
>     }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message