Fixed an issue on how loggers are initialized

This commit is contained in:
Isaac Parenteau
2018-09-15 16:00:51 -05:00
parent 16e8ab5eb1
commit 99894f9acd
2 changed files with 10 additions and 6 deletions

View File

@ -516,16 +516,20 @@ public class ApplicationLogger implements org.slf4j.Logger {
switch (level) { switch (level) {
case ALL: case ALL:
case TRACE: case TRACE:
logger.trace(format(message, level));
break;
case DEBUG: case DEBUG:
logger.debug(format(message, level));
break;
case INFO: case INFO:
logger.info(format(message)); logger.info(format(message, level));
break; break;
case WARN: case WARN:
logger.warn(format(message)); logger.warn(format(message, level));
break; break;
case ERROR: case ERROR:
case FATAL: case FATAL:
logger.error(format(message)); logger.error(format(message, level));
break; break;
case OFF: case OFF:
default: default:
@ -615,7 +619,7 @@ public class ApplicationLogger implements org.slf4j.Logger {
* @param message the message to log * @param message the message to log
* @return the formatted string * @return the formatted string
*/ */
private String format(String message) { private String format(String message, LogLevel level) {
return String.format("th%06d [%-5s] [%s] %s", Thread.currentThread().getId(), this.level.name(), this.name, message); return String.format("th%06d [%-5s] [%s] %s", Thread.currentThread().getId(), level, this.name, message);
} }
} }

View File

@ -13,7 +13,7 @@ import java.util.stream.Collectors;
*/ */
public class ApplicationLoggerFactory { public class ApplicationLoggerFactory {
private static Map<String, ApplicationLogger> loggers = new TreeMap<>(); private static Map<String, ApplicationLogger> loggers = new TreeMap<>();
private static LogLevel DEFAULT_LEVEL = null; private static LogLevel DEFAULT_LEVEL = LogLevel.ALL;
private static ApplicationLoggerInitializer initializer; private static ApplicationLoggerInitializer initializer;
/** /**