[slf4j-dev] [GIT] SLF4J: Simple Logging Facade for Java branch master updated. v_1.7.0-9-ge8b0826
Gitbot
git-noreply at pixie.qos.ch
Fri Sep 14 21:19:57 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 e8b082611b42cb319136fb95bac45a32e7f72b1c (commit)
from 37579087aa061cf2861f2aee6fc35a8f17017708 (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=e8b082611b42cb319136fb95bac45a32e7f72b1c
http://github.com/ceki/slf4j/commit/e8b082611b42cb319136fb95bac45a32e7f72b1c
commit e8b082611b42cb319136fb95bac45a32e7f72b1c
Author: Ceki Gulcu <ceki at qos.ch>
Date: Fri Sep 14 21:19:17 2012 +0200
delay initialization until first logger is invoked
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 c5540f3..87f525c 100644
--- a/slf4j-simple/src/main/java/org/slf4j/impl/SimpleLogger.java
+++ b/slf4j-simple/src/main/java/org/slf4j/impl/SimpleLogger.java
@@ -48,13 +48,14 @@ import org.slf4j.spi.LocationAwareLogger;
* The following system properties are supported to configure the behavior of this logger:</p>
* <ul>
* <li><code>org.slf4j.simpleLogger.defaultLog</code> -
- * Default logging detail level for all instances of SimpleLogger.
+ * Default logging level for all instances of SimpleLogger.
* Must be one of ("trace", "debug", "info", "warn", or "error").
* If not specified, defaults to "info". </li>
* <li><code>org.slf4j.simpleLogger.log.xxxxx</code> -
* Logging detail level for a SimpleLogger instance named "xxxxx".
* Must be one of ("trace", "debug", "info", "warn", or "error").
- * If not specified, the default logging detail level is used.</li>
+ * If not specified, the level of parent logger will be used, and if none is set, then
+ * the default level is used.</li>
* <li><code>org.slf4j.simpleLogger.showDateTime</code> -
* Set to <code>true</code> if you want the current date and time
* to be included in output messages. Default is <code>true</code></li>
@@ -112,21 +113,30 @@ public class SimpleLogger extends MarkerIgnoringBase {
private static long START_TIME = System.currentTimeMillis();
private static final Properties SIMPLE_LOGGER_PROPS = new Properties();
- private static boolean SHOW_LOG_NAME = true;
+
+ private static final int LOG_LEVEL_TRACE = LocationAwareLogger.TRACE_INT;
+ private static final int LOG_LEVEL_DEBUG = LocationAwareLogger.DEBUG_INT;
+ private static final int LOG_LEVEL_INFO = LocationAwareLogger.INFO_INT;
+ private static final int LOG_LEVEL_WARN = LocationAwareLogger.WARN_INT;
+ private static final int LOG_LEVEL_ERROR = LocationAwareLogger.ERROR_INT;
+
+ private static int DEFAULT_LOG_LEVEL = LOG_LEVEL_INFO;
+
+
private static boolean SHOW_SHORT_LOG_NAME = false;
private static boolean SHOW_DATE_TIME = false;
+
private static String DATE_TIME_FORMAT_STR = null;
private static boolean SHOW_THREAD_NAME = true;
+ private static boolean SHOW_LOG_NAME = true;
+
+
private static String LOG_FILE = "System.err";
private static boolean LEVEL_IN_BRACKETS = false;
private static DateFormat DATE_FORMATTER = null;
- private static final int LOG_LEVEL_TRACE = LocationAwareLogger.TRACE_INT;
- private static final int LOG_LEVEL_DEBUG = LocationAwareLogger.DEBUG_INT;
- private static final int LOG_LEVEL_INFO = LocationAwareLogger.INFO_INT;
- private static final int LOG_LEVEL_WARN = LocationAwareLogger.WARN_INT;
- private static final int LOG_LEVEL_ERROR = LocationAwareLogger.ERROR_INT;
+ private static boolean INITIALIZED = false;
/**
* All system properties used by <code>SimpleLogger</code> start with this prefix
@@ -140,13 +150,12 @@ public class SimpleLogger extends MarkerIgnoringBase {
public static final String DATE_TIME_FORMAT_KEY = SYSTEM_PREFIX + "dateTimeFormat";
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 = null;
private static String getStringProperty(String name) {
@@ -173,10 +182,10 @@ public class SimpleLogger extends MarkerIgnoringBase {
// Initialize class attributes.
// Load properties file, if found.
// Override with system properties.
- static {
+ static void init() {
+ INITIALIZED = true;
loadProperties();
-
String defaultLogLevelString = getStringProperty(DEFAULT_LOG_KEY, null);
if (defaultLogLevelString != null)
DEFAULT_LOG_LEVEL = stringToLevel(defaultLogLevelString);
@@ -188,7 +197,6 @@ public class SimpleLogger extends MarkerIgnoringBase {
DATE_TIME_FORMAT_STR = getStringProperty(DATE_TIME_FORMAT_KEY, DATE_TIME_FORMAT_STR);
LEVEL_IN_BRACKETS = getBooleanProperty(LEVEL_IN_BRACKETS_KEY, LEVEL_IN_BRACKETS);
-
LOG_FILE = getStringProperty(LOG_FILE_KEY, LOG_FILE);
TARGET_STREAM = computeTargetStream(LOG_FILE);
@@ -201,6 +209,8 @@ public class SimpleLogger extends MarkerIgnoringBase {
}
}
+
+
private static PrintStream computeTargetStream(String logFile) {
if ("System.err".equalsIgnoreCase(logFile))
return System.err;
@@ -258,6 +268,9 @@ public class SimpleLogger extends MarkerIgnoringBase {
* SimpleLogger instances.
*/
SimpleLogger(String name) {
+ if(!INITIALIZED) {
+ init();
+ }
this.name = name;
String levelString = recursivelyComputeLevelString();
-----------------------------------------------------------------------
Summary of changes:
.../src/main/java/org/slf4j/impl/SimpleLogger.java | 39 +++++++++++++-------
1 files changed, 26 insertions(+), 13 deletions(-)
hooks/post-receive
--
SLF4J: Simple Logging Facade for Java
More information about the slf4j-dev
mailing list