Uploaded image for project: 'MINA'
  1. MINA
  2. DIRMINA-656

Methods log in LoggingFilter.java use the subsequent eventLevel instead of current

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.0.0-M4
    • 2.0.0-M5
    • Filter
    • None
    • Windows-XP SP3
      jdk1.6.0_11

    Description

      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)
        Unknown macro: { 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)
        Unknown macro: { 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)
        Unknown macro: { 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; } }

      Attachments

        Activity

          People

            elecharny Emmanuel Lécharny
            aris Aris Marsopoulos
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 5m
                5m
                Remaining:
                Remaining Estimate - 5m
                5m
                Logged:
                Time Spent - Not Specified
                Not Specified