From 04dfafe19f0d3687d0f0b3e51d2d5bf3d19b58bf Mon Sep 17 00:00:00 2001
From: boli <boli@localhost>
Date: Wed, 07 Mar 2007 23:38:55 +0000
Subject: [PATCH] Enable AspectJ weaving for the new debug logging framework: - This commit does not allow for configuring the debug logger over protocol. It can only be configured on server startup using properties. - The settings specified during startup will remain in effect for the duration of the server. - All messages are printed to standard out. - Weaving could be turned off with the -DDEBUG_BUILD=false property when building the server. - By default, the debug logger is off on server startup. It could be enabled by using the -Dorg.opends.server.debug.enabled=true. - Debug targets may be defined with the -Dorg.opends.server.debug.target property. The syntax of this property can be found on the opends.dev.java.net documentation section. - Debug logging is turned on by default on unit tests and printed on test failure.  - Default debug target for unit tests could be changed by using the -Dorg.opends.test.debug.target property.

---
 opends/src/server/org/opends/server/loggers/debug/DebugLogger.java |   74 +++++++++++--------------------------
 1 files changed, 22 insertions(+), 52 deletions(-)

diff --git a/opends/src/server/org/opends/server/loggers/debug/DebugLogger.java b/opends/src/server/org/opends/server/loggers/debug/DebugLogger.java
index f3013aa..f00b353 100644
--- a/opends/src/server/org/opends/server/loggers/debug/DebugLogger.java
+++ b/opends/src/server/org/opends/server/loggers/debug/DebugLogger.java
@@ -27,10 +27,8 @@
 package org.opends.server.loggers.debug;
 
 import org.opends.server.api.ProtocolElement;
-import org.opends.server.api.LogPublisher;
 import org.opends.server.loggers.Logger;
 import org.opends.server.loggers.LogLevel;
-import org.opends.server.loggers.LogRecord;
 
 import java.util.Map;
 import java.util.HashMap;
@@ -55,35 +53,21 @@
  */
 public class DebugLogger extends Logger
 {
-  /**
-   * Whether the debug logger is enabled or disabled.
-   */
-  static boolean enabled = false;
   private static DebugLogger logger = null;
+  static boolean staticEnabled = false;
 
   private Map<String, Tracer> classTracers;
-  private TraceConfiguration config;
 
-  private DebugLogger()
+  private DebugConfiguration configuration;
+
+  private DebugLogger(DebugConfiguration config)
   {
-    super(new DebugErrorHandler());
-
+    super(config);
+    configuration = config;
     classTracers = new HashMap<String, Tracer>();
-    config = new TraceConfiguration();
+    staticEnabled = enabled;
   }
 
-  /**
-   * Publish a record to all the registered publishers.
-   *
-   * @param record The log record to publish.
-   */
-  protected void publishRecord(LogRecord record)
-  {
-    for(LogPublisher p : publishers)
-    {
-      p.publish(record, handler);
-    }
-  }
 
   /**
    * Obtain the trace logger singleton.
@@ -92,30 +76,26 @@
   public static synchronized DebugLogger getLogger()
   {
     if (logger == null) {
-      logger= new DebugLogger();
+      /**
+       * The debug logger is being intialized for the first time.
+       * Bootstrap the debug logger when the server first starts up so
+       * all debug messages are log from the first initialization of a
+       * server class.
+       */
+      logger= new DebugLogger(DebugConfiguration.getStartupConfiguration());
     }
 
     return logger;
   }
 
   /**
-   * Enable or disable the debug logger.
-   *
-   * @param enable if the debug logger should be enabled.
-   */
-  public static void enabled(boolean enable)
-  {
-    enabled = enable;
-  }
-
-  /**
    * Obtain the status of this logger singleton.
    *
    * @return the status of this logger.
    */
   public static boolean debugEnabled()
   {
-    return enabled;
+    return staticEnabled;
   }
 
   /**
@@ -129,21 +109,8 @@
     Tracer traceLogger = classTracers.get(className);
     if (traceLogger == null) {
       classTracers.put(className, tracer);
+      tracer.updateSettings(this.configuration);
     }
-    else
-    {
-      //TODO: handle dup case!
-    }
-  }
-
-  /**
-   * Retrives the current tracing configuration of the debug logger.
-   *
-   * @return the current tracing configuration of the debug logger.
-   */
-  protected TraceConfiguration getConfiguration()
-  {
-    return config;
   }
 
   /**
@@ -152,14 +119,17 @@
    *
    * @param config the new configuration to apply.
    */
-  public void updateConfiguration(TraceConfiguration config)
+  public synchronized void updateConfiguration(DebugConfiguration config)
   {
-    this.config = config;
+    super.updateConfiguration(config);
+    staticEnabled = enabled;
 
     for(Tracer tracer : classTracers.values())
     {
-      tracer.updateSettings();
+      tracer.updateSettings(config);
     }
+
+    this.configuration = config;
   }
 
   /**

--
Gitblit v1.10.0