From 5d1a7f43aa3104bd4047839897a65066c555f7a9 Mon Sep 17 00:00:00 2001
From: Nicolas Capponi <nicolas.capponi@forgerock.com>
Date: Thu, 13 Feb 2014 13:00:25 +0000
Subject: [PATCH] Checkpoint commit for OPENDJ-1288 : Migrate I18n and logging support to i18n framework and SLF4J
---
opendj3-server-dev/src/server/org/opends/server/loggers/TextDebugLogPublisher.java | 60 +++++++++++++++++++++++++-----------------------------------
1 files changed, 25 insertions(+), 35 deletions(-)
diff --git a/opendj3-server-dev/src/server/org/opends/server/loggers/TextDebugLogPublisher.java b/opendj3-server-dev/src/server/org/opends/server/loggers/TextDebugLogPublisher.java
index bed74b6..d51cebd 100644
--- a/opendj3-server-dev/src/server/org/opends/server/loggers/TextDebugLogPublisher.java
+++ b/opendj3-server-dev/src/server/org/opends/server/loggers/TextDebugLogPublisher.java
@@ -31,7 +31,6 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import org.forgerock.i18n.LocalizableMessage;
import org.opends.server.admin.server.ConfigurationAddListener;
@@ -52,7 +51,6 @@
import org.opends.server.util.TimeThread;
import static org.opends.messages.ConfigMessages.*;
-import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
/**
@@ -73,46 +71,39 @@
private FileBasedDebugLogPublisherCfg currentConfig;
/**
- * Returns an instance of the text debug log publisher that will print
- * all messages to the provided writer. This is used to print the messages
- * to the console when the server starts up. By default, only error level
- * messages are printed. Special debug targets are also parsed from
- * system properties if any are specified.
+ * Returns an instance of the text debug log publisher that will print all
+ * messages to the provided writer, based on the provided debug targets.
*
- * @param writer The text writer where the message will be written to.
- * @return The instance of the text error log publisher that will print
- * all messages to standard out.
+ * @param debugTargets
+ * The targets defining which and how debug events are logged.
+ * @param writer
+ * The text writer where the message will be written to.
+ * @return The instance of the text error log publisher that will print all
+ * messages to standard out. May be {@code null} if no debug target is
+ * valid.
*/
- public static TextDebugLogPublisher
- getStartupTextDebugPublisher(TextWriter writer)
+ static TextDebugLogPublisher getStartupTextDebugPublisher(List<String> debugTargets, TextWriter writer)
{
- TextDebugLogPublisher startupPublisher = new TextDebugLogPublisher();
- startupPublisher.writer = writer;
-
- Set<Map.Entry<Object, Object>> propertyEntries =
- System.getProperties().entrySet();
- for(Map.Entry<Object, Object> entry : propertyEntries)
+ TextDebugLogPublisher startupPublisher = null;
+ for (String value : debugTargets)
{
- if(((String)entry.getKey()).startsWith(PROPERTY_DEBUG_TARGET))
- {
- String value = (String)entry.getValue();
- int settingsStart= value.indexOf(":");
+ int settingsStart = value.indexOf(":");
- //See if the scope and settings exists
- if(settingsStart > 0)
+ //See if the scope and settings exists
+ if (settingsStart > 0)
+ {
+ String scope = value.substring(0, settingsStart);
+ TraceSettings settings = TraceSettings.parseTraceSettings(value.substring(settingsStart + 1));
+ if (settings != null)
{
- String scope = value.substring(0, settingsStart);
- TraceSettings settings =
- TraceSettings.parseTraceSettings(
- value.substring(settingsStart+1));
- if(settings != null)
- {
- startupPublisher.addTraceSettings(scope, settings);
+ if (startupPublisher == null) {
+ startupPublisher = new TextDebugLogPublisher();
+ startupPublisher.writer = writer;
}
+ startupPublisher.addTraceSettings(scope, settings);
}
}
}
-
return startupPublisher;
}
@@ -342,9 +333,8 @@
private TraceSettings getDefaultSettings(FileBasedDebugLogPublisherCfg config)
{
- return new TraceSettings(TraceSettings.Level.getLevel(
- false,
- config.isDefaultDebugExceptionsOnly()),
+ return new TraceSettings(
+ TraceSettings.Level.getLevel(true, config.isDefaultDebugExceptionsOnly()),
config.isDefaultOmitMethodEntryArguments(),
config.isDefaultOmitMethodReturnValue(),
config.getDefaultThrowableStackFrames(),
--
Gitblit v1.10.0