[slf4j-dev] [GIT] SLF4J: Simple Logging Facade for Java branch master updated. v_1.7.0-8-g3757908
Gitbot
git-noreply at pixie.qos.ch
Fri Sep 14 20:52:36 CEST 2012
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "SLF4J: Simple Logging Facade for Java".
The branch, master has been updated
via 37579087aa061cf2861f2aee6fc35a8f17017708 (commit)
from 996ccc7ca507994465c069554954ecb01890d4d5 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=slf4j.git;a=commit;h=37579087aa061cf2861f2aee6fc35a8f17017708
http://github.com/ceki/slf4j/commit/37579087aa061cf2861f2aee6fc35a8f17017708
commit 37579087aa061cf2861f2aee6fc35a8f17017708
Author: Ceki Gulcu <ceki at qos.ch>
Date: Fri Sep 14 20:51:56 2012 +0200
added levelInBrackets option
diff --git a/slf4j-simple/src/main/java/org/slf4j/impl/SimpleLogger.java b/slf4j-simple/src/main/java/org/slf4j/impl/SimpleLogger.java
index 2995b5f..c5540f3 100644
--- a/slf4j-simple/src/main/java/org/slf4j/impl/SimpleLogger.java
+++ b/slf4j-simple/src/main/java/org/slf4j/impl/SimpleLogger.java
@@ -117,7 +117,8 @@ public class SimpleLogger extends MarkerIgnoringBase {
private static boolean SHOW_DATE_TIME = false;
private static String DATE_TIME_FORMAT_STR = null;
private static boolean SHOW_THREAD_NAME = true;
- private static String logFile = "System.err";
+ private static String LOG_FILE = "System.err";
+ private static boolean LEVEL_IN_BRACKETS = false;
private static DateFormat DATE_FORMATTER = null;
@@ -140,11 +141,13 @@ public class SimpleLogger extends MarkerIgnoringBase {
public static final String SHOW_DATE_TIME_KEY = SYSTEM_PREFIX + "showDateTime";
public static final String LOG_FILE_KEY = SYSTEM_PREFIX + "logFile";
+ public static final String LEVEL_IN_BRACKETS_KEY = SYSTEM_PREFIX + "levelInBrackets";
+
public static final String LOG_KEY_PREFIX = SYSTEM_PREFIX + "log.";
private static int DEFAULT_LOG_LEVEL = LOG_LEVEL_INFO;
- private static PrintStream TARGET_STREAM = System.err;
+ private static PrintStream TARGET_STREAM = null;
private static String getStringProperty(String name) {
String prop = null;
@@ -183,10 +186,11 @@ public class SimpleLogger extends MarkerIgnoringBase {
SHOW_DATE_TIME = getBooleanProperty(SHOW_DATE_TIME_KEY, SHOW_DATE_TIME);
SHOW_THREAD_NAME = getBooleanProperty(SHOW_THREAD_NAME_KEY, SHOW_THREAD_NAME);
DATE_TIME_FORMAT_STR = getStringProperty(DATE_TIME_FORMAT_KEY, DATE_TIME_FORMAT_STR);
+ LEVEL_IN_BRACKETS = getBooleanProperty(LEVEL_IN_BRACKETS_KEY, LEVEL_IN_BRACKETS);
- logFile = getStringProperty(LOG_FILE_KEY, logFile);
- TARGET_STREAM = computeTargetStream(logFile);
+ LOG_FILE = getStringProperty(LOG_FILE_KEY, LOG_FILE);
+ TARGET_STREAM = computeTargetStream(LOG_FILE);
if (DATE_TIME_FORMAT_STR != null) {
try {
@@ -198,9 +202,9 @@ public class SimpleLogger extends MarkerIgnoringBase {
}
private static PrintStream computeTargetStream(String logFile) {
- if("System.err".equalsIgnoreCase(logFile))
+ if ("System.err".equalsIgnoreCase(logFile))
return System.err;
- else if("System.out".equalsIgnoreCase(logFile)) {
+ else if ("System.out".equalsIgnoreCase(logFile)) {
return System.out;
} else {
try {
@@ -277,16 +281,16 @@ public class SimpleLogger extends MarkerIgnoringBase {
return levelString;
}
- private static int stringToLevel(String lvl) {
- if ("trace".equalsIgnoreCase(lvl)) {
+ private static int stringToLevel(String levelStr) {
+ if ("trace".equalsIgnoreCase(levelStr)) {
return LOG_LEVEL_TRACE;
- } else if ("debug".equalsIgnoreCase(lvl)) {
+ } else if ("debug".equalsIgnoreCase(levelStr)) {
return LOG_LEVEL_DEBUG;
- } else if ("info".equalsIgnoreCase(lvl)) {
+ } else if ("info".equalsIgnoreCase(levelStr)) {
return LOG_LEVEL_INFO;
- } else if ("warn".equalsIgnoreCase(lvl)) {
+ } else if ("warn".equalsIgnoreCase(levelStr)) {
return LOG_LEVEL_WARN;
- } else if ("error".equalsIgnoreCase(lvl)) {
+ } else if ("error".equalsIgnoreCase(levelStr)) {
return LOG_LEVEL_ERROR;
}
// assume INFO by default
@@ -327,6 +331,8 @@ public class SimpleLogger extends MarkerIgnoringBase {
buf.append("] ");
}
+ if (LEVEL_IN_BRACKETS) buf.append('[');
+
// Append a readable representation of the log level
switch (level) {
case LOG_LEVEL_TRACE:
@@ -345,6 +351,7 @@ public class SimpleLogger extends MarkerIgnoringBase {
buf.append("ERROR");
break;
}
+ if (LEVEL_IN_BRACKETS) buf.append(']');
buf.append(' ');
// Append the name of the log instance if so configured
@@ -364,7 +371,6 @@ public class SimpleLogger extends MarkerIgnoringBase {
void write(StringBuffer buf, Throwable t) {
TARGET_STREAM.println(buf.toString());
- // Append stack trace if not null
if (t != null) {
t.printStackTrace(TARGET_STREAM);
}
-----------------------------------------------------------------------
Summary of changes:
.../src/main/java/org/slf4j/impl/SimpleLogger.java | 32 ++++++++++++--------
1 files changed, 19 insertions(+), 13 deletions(-)
hooks/post-receive
--
SLF4J: Simple Logging Facade for Java
More information about the slf4j-dev
mailing list