| | |
| | | |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.Map; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
| | |
| | | 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); |
| | |
| | | |
| | | /** {@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(); |
| | | } |
| | | |
| | | /** |
| | |
| | | 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; |
| | | } |
| | | |
| | | } |