mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Nicolas Capponi
06.51.2014 10bac0ad21fca0c5ac8bf6d7dc712c5899c2d0e6
opendj3-server-dev/src/server/org/opends/server/loggers/DebugLogger.java
@@ -28,6 +28,7 @@
import static org.opends.messages.ConfigMessages.*;
import java.util.Collection;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -67,13 +68,13 @@
      loggerStorage = new LoggerStorage
      <DebugLogPublisher<DebugLogPublisherCfg>, DebugLogPublisherCfg>();
  /** The singleton instance of this class for configuration purposes. */
  /** The singleton instance of this class. */
  static final DebugLogger instance = new DebugLogger();
  /**
   * The constructor for this class.
   */
  public DebugLogger()
  private DebugLogger()
  {
    super((Class) DebugLogPublisher.class,
        ERR_CONFIG_LOGGER_INVALID_DEBUG_LOGGER_CLASS);
@@ -89,55 +90,9 @@
  /** {@inheritDoc} */
  @Override
  protected LoggerStorage<DebugLogPublisher<DebugLogPublisherCfg>,
      DebugLogPublisherCfg> getStorage()
  protected Collection<DebugLogPublisher<DebugLogPublisherCfg>> getLogPublishers()
  {
    return loggerStorage;
  }
  /**
   * Add an debug log publisher to the debug logger.
   *
   * @param publisher The debug log publisher to add.
   */
  public synchronized static void addDebugLogPublisher(
      DebugLogPublisher publisher)
  {
    loggerStorage.addLogPublisher(publisher);
    updateTracerSettings();
    enabled = true;
  }
  /**
   * Remove an debug log publisher from the debug logger.
   *
   * @param publisher The debug log publisher to remove.
   * @return The publisher that was removed or null if it was not found.
   */
  public synchronized static boolean removeDebugLogPublisher(
      DebugLogPublisher publisher)
  {
    boolean removed = loggerStorage.removeLogPublisher(publisher);
    updateTracerSettings();
    enabled = !loggerStorage.getLogPublishers().isEmpty();
    return removed;
  }
  /**
   * Removes all existing debug log publishers from the logger.
   */
  public synchronized static void removeAllDebugLogPublishers()
  {
    loggerStorage.removeAllLogPublishers();
    updateTracerSettings();
    enabled = false;
    return loggerStorage.getLogPublishers();
  }
  /**
@@ -195,4 +150,34 @@
    return tracer;
  }
  /** {@inheritDoc} */
  @Override
  public final synchronized void addLogPublisher(
      DebugLogPublisher<DebugLogPublisherCfg> publisher)
  {
    loggerStorage.addLogPublisher(publisher);
    updateTracerSettings();
    enabled = true;
  }
  /** {@inheritDoc} */
  @Override
  public final synchronized boolean removeLogPublisher(
      DebugLogPublisher<DebugLogPublisherCfg> publisher)
  {
    boolean removed = loggerStorage.removeLogPublisher(publisher);
    updateTracerSettings();
    enabled = !loggerStorage.getLogPublishers().isEmpty();
    return removed;
  }
  /** {@inheritDoc} */
  @Override
  public final synchronized void removeAllLogPublishers()
  {
    loggerStorage.removeAllLogPublishers();
    updateTracerSettings();
    enabled = false;
  }
}