Example #1
0
 /**
  * Checks if a message of the given level would actually be logged by this logger.
  *
  * @param level the message logging level
  * @return <code>true</code> if a message of specified level would actually be logged;<code>false
  *     </code> otherwise.
  */
 public static boolean isLoggable(Level level) {
   LogContext log = (LogContext) LogContext.getCurrent();
   if (log instanceof StandardLog) {
     return ((StandardLog) log)._logger.isLoggable(level);
   } else if (level.intValue() >= Level.WARNING.intValue()) {
     return log.isWarningLogged();
   } else if (level.intValue() >= Level.INFO.intValue()) {
     return log.isInfoLogged();
   } else {
     return false;
   }
 }
Example #2
0
 /**
  * Log a specific LogRecord. If the current logging context is not a {@link StandardLog}, an
  * {@link LogContext#logError error}, {@link LogContext#logWarning warning} or {@link
  * LogContext#logInfo info} is possibly logged.
  *
  * @param record the LogRecord to be published.
  */
 public static void log(LogRecord record) {
   LogContext log = (LogContext) LogContext.getCurrent();
   if (log instanceof StandardLog) {
     ((StandardLog) log)._logger.log(record);
   } else {
     Throwable error = record.getThrown();
     if (error != null) {
       if (log.isErrorLogged()) {
         log.logError(error, Javolution.j2meToCharSeq(record.getMessage()));
       }
     } else if (record.getLevel().intValue() > Level.WARNING.intValue()) {
       if (log.isWarningLogged()) {
         log.logWarning(Javolution.j2meToCharSeq(record.getMessage()));
       }
     } else if (record.getLevel().intValue() > Level.INFO.intValue()) {
       if (log.isInfoLogged()) {
         log.logInfo(Javolution.j2meToCharSeq(record.getMessage()));
       }
     }
   }
 }