| | |
| | | * |
| | | * |
| | | * Copyright 2007-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013 ForgeRock AS |
| | | * Portions Copyright 2013-2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.loggers.debug; |
| | | |
| | |
| | | import org.opends.server.admin.std.server.DebugLogPublisherCfg; |
| | | import org.opends.server.api.DebugLogPublisher; |
| | | import org.opends.server.loggers.AbstractLogger; |
| | | import org.opends.server.loggers.LogLevel; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | |
| | | /** |
| | | * A logger for debug and trace logging. DebugLogger provides a debugging |
| | |
| | | public class DebugLogger extends AbstractLogger |
| | | <DebugLogPublisher<DebugLogPublisherCfg>, DebugLogPublisherCfg> |
| | | { |
| | | /** The default level to log constructor executions. */ |
| | | static final LogLevel DEFAULT_CONSTRUCTOR_LEVEL = |
| | | DebugLogLevel.VERBOSE; |
| | | /** The default level to log method entry and exit pointcuts. */ |
| | | static final LogLevel DEFAULT_ENTRY_EXIT_LEVEL = |
| | | DebugLogLevel.VERBOSE; |
| | | /** The default level to log method entry and exit pointcuts. */ |
| | | static final LogLevel DEFAULT_THROWN_LEVEL = |
| | | DebugLogLevel.ERROR; |
| | | |
| | | /** The set of all DebugTracer instances. */ |
| | | private static Map<String, DebugTracer> classTracers = |
| | |
| | | */ |
| | | public static DebugTracer getTracer() |
| | | { |
| | | DebugTracer tracer = |
| | | new DebugTracer(loggerStorage.getLogPublishers().toArray( |
| | | new DebugLogPublisher[0])); |
| | | classTracers.put(tracer.getTracedClassName(), tracer); |
| | | |
| | | return tracer; |
| | | // TODO : remove this method |
| | | return getTracer("org.opends"); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public static DebugTracer getTracer(String className) |
| | | { |
| | | return classTracers.get(className); |
| | | DebugTracer tracer = classTracers.get(className); |
| | | if (tracer == null) |
| | | { |
| | | tracer = |
| | | new DebugTracer(className, loggerStorage.getLogPublishers().toArray( |
| | | new DebugLogPublisher[0])); |
| | | classTracers.put(tracer.getTracedClassName(), tracer); |
| | | } |
| | | return tracer; |
| | | } |
| | | |
| | | /** |
| | | * Classes and methods annotated with @NoDebugTracing will not be weaved with |
| | | * debug logging statements by AspectJ. |
| | | */ |
| | | public @interface NoDebugTracing {} |
| | | |
| | | /** |
| | | * Methods annotated with @NoEntryDebugTracing will not be weaved with |
| | | * entry debug logging statements by AspectJ. |
| | | */ |
| | | public @interface NoEntryDebugTracing {} |
| | | |
| | | /** |
| | | * Methods annotated with @NoExitDebugTracing will not be weaved with |
| | | * exit debug logging statements by AspectJ. |
| | | */ |
| | | public @interface NoExitDebugTracing {} |
| | | |
| | | /** |
| | | * Methods annotated with @TraceThrown will be weaved by AspectJ with |
| | | * debug logging statements when an exception is thrown from the method. |
| | | */ |
| | | public @interface TraceThrown {} |
| | | |
| | | } |