| | |
| | | import org.opends.server.util.ServerConstants; |
| | | import org.opends.server.util.StaticUtils; |
| | | import org.opends.server.api.ProtocolElement; |
| | | import org.opends.server.api.DirectoryThread; |
| | | import org.opends.server.loggers.*; |
| | | import org.opends.server.types.DebugLogCategory; |
| | | import org.opends.server.types.DebugLogLevel; |
| | |
| | | * Logging is always done at a level basis, with debug log messages |
| | | * exceeding the trace threshold being traced, others being discarded. |
| | | */ |
| | | @Aspect("pertypewithin(*)") |
| | | @Aspect("pertypewithin(!@Tracer.NoDebugTracing org.opends.server..*+ && " + |
| | | "!org.opends.server.loggers.*+ && " + |
| | | "!org.opends.server.loggers.debug..*+ &&" + |
| | | "!org.opends.server.types.DebugLogLevel+ && " + |
| | | "!org.opends.server.types.DebugLogCategory+)") |
| | | public class Tracer |
| | | { |
| | | /** |
| | |
| | | /** |
| | | * Pointcut for matching all toString() methods. |
| | | */ |
| | | @Pointcut("execution(String *..toString())") |
| | | @Pointcut("execution(* *..toString(..))") |
| | | private void toStringMethod() |
| | | { |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * Pointcut for matching all getDebugProperties() methods. |
| | | * TODO: Make this less general. Find out if pointcut matches |
| | | * subclass methods. |
| | | */ |
| | | @Pointcut("execution(* *..getDebugProperties(..))") |
| | | private void getDebugPropertiesMethod() |
| | | { |
| | | } |
| | | |
| | | /** |
| | | * Pointcut for matching debugMessage() methods. |
| | | */ |
| | | @Pointcut("call(public static void org.opends.server." + |
| | |
| | | * Pointcut to exclude all pointcuts which should not be adviced by the |
| | | * debug logger. |
| | | */ |
| | | @Pointcut("within(Tracer+) || within(org.opends.server.loggers.debug..*) " + |
| | | "|| toStringMethod() " + |
| | | "|| getMessageMethod() || logMethods()") |
| | | @Pointcut("toStringMethod() || getMessageMethod() || " + |
| | | "getDebugPropertiesMethod() || logMethods()") |
| | | private void excluded() |
| | | { |
| | | } |
| | |
| | | /** |
| | | * Pointcut for matching the execution of all public methods. |
| | | */ |
| | | @Pointcut("execution(!@NoDebugTracing public * *(..)) && !excluded()") |
| | | void tracedMethod() |
| | | @Pointcut("execution(!@(Tracer.NoDebugTracing || " + |
| | | "Tracer.NoEntryDebugTracing) public * *(..)) && " + |
| | | "!excluded()") |
| | | void tracedEntryMethod() |
| | | { |
| | | } |
| | | |
| | | /** |
| | | * Pointcut for matching the execution of all public methods. |
| | | */ |
| | | @Pointcut("execution(!@(Tracer.NoDebugTracing || " + |
| | | "Tracer.NoExitDebugTracing) public * *(..)) && " + |
| | | "!excluded()") |
| | | void tracedExitMethod() |
| | | { |
| | | } |
| | | |
| | | /** |
| | | * Pointcut for matching the execution of all public methods. |
| | | */ |
| | | @Pointcut("execution(@Tracer.TraceThrown public * *(..)) && " + |
| | | "!excluded()") |
| | | void tracedThrownMethod() |
| | | { |
| | | } |
| | | |
| | | /** |
| | | * Pointcut for matching the execution of all constructors. |
| | | */ |
| | | @Pointcut("execution(!@NoDebugTracing public new(..)) && !excluded()") |
| | | void tracedConstructor() |
| | | @Pointcut("execution(!@(Tracer.NoDebugTracing || " + |
| | | "Tracer.NoEntryDebugTracing) public new(..)) && !excluded()") |
| | | void tracedEntryConstructor() |
| | | { |
| | | } |
| | | |
| | | /** |
| | | * Pointcut for matching the execution of all constructors. |
| | | */ |
| | | @Pointcut("execution(!@(Tracer.NoDebugTracing || " + |
| | | "Tracer.NoExitDebugTracing) public new(..)) && !excluded()") |
| | | void tracedExitConstructor() |
| | | { |
| | | } |
| | | |
| | |
| | | * |
| | | * @return if debug logging is enabled. |
| | | */ |
| | | @Pointcut("if() && tracingScope()") |
| | | @Pointcut("if()") |
| | | public static boolean shouldTrace() |
| | | { |
| | | return DebugLogger.enabled; |
| | | return DebugLogger.staticEnabled; |
| | | } |
| | | |
| | | /** |
| | | * Pointcut for matching only within the scope of the server packages. |
| | | */ |
| | | @Pointcut("within(!@NoDebugTracing org.opends.server..*)") |
| | | protected void tracingScope() |
| | | { |
| | | } |
| | | |
| | | //The default level to log constructor exectuions. |
| | | private static final LogLevel DEFAULT_CONSTRUCTOR_LEVEL = |
| | |
| | | //The default level to log method entry and exit pointcuts. |
| | | private static final LogLevel DEFAULT_ENTRY_EXIT_LEVEL = |
| | | DebugLogLevel.VERBOSE; |
| | | //The default level to log method entry and exit pointcuts. |
| | | private static final LogLevel DEFAULT_THROWN_LEVEL = |
| | | DebugLogLevel.ERROR; |
| | | |
| | | private static final DebugMessageFormatter msgFormatter = |
| | | new DebugMessageFormatter(); |
| | | |
| | | // The class this tracer traces. |
| | | private String className; |
| | |
| | | * |
| | | * @param thisJoinPointStaticPart the JoinPoint reflection object. |
| | | */ |
| | | @Before("staticinitialization(*) && tracingScope()") |
| | | @Before("staticinitialization(*)") |
| | | public void initializeTracer(JoinPoint.StaticPart thisJoinPointStaticPart) |
| | | { |
| | | className = thisJoinPointStaticPart.getSignature().getDeclaringTypeName(); |
| | | logger = DebugLogger.getLogger(); |
| | | logger.registerTracer(className, this); |
| | | updateSettings(); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @param thisJoinPoint the JoinPoint reflection object. |
| | | */ |
| | | @Before("shouldTrace() && tracedConstructor()") |
| | | @Before("shouldTrace() && tracedEntryConstructor()") |
| | | public void traceConstructor(JoinPoint thisJoinPoint) |
| | | { |
| | | LogCategory category = DebugLogCategory.CONSTRUCTOR; |
| | |
| | | * @param thisJoinPoint the JoinPoint reflection object. |
| | | * @param obj the object this method operations on. |
| | | */ |
| | | @Before("shouldTrace() && tracedMethod() && nonStaticContext(obj)") |
| | | @Before("shouldTrace() && tracedEntryMethod() && nonStaticContext(obj)") |
| | | public void traceNonStaticMethodEntry(JoinPoint thisJoinPoint, Object obj) |
| | | { |
| | | LogCategory category = DebugLogCategory.ENTER; |
| | |
| | | * |
| | | * @param thisJoinPoint the JoinPoint reflection object. |
| | | */ |
| | | @Before("shouldTrace() && tracedMethod() && staticContext()") |
| | | @Before("shouldTrace() && tracedEntryMethod() && staticContext()") |
| | | public void traceStaticMethodEntry(JoinPoint thisJoinPoint) |
| | | { |
| | | LogCategory category = DebugLogCategory.ENTER; |
| | |
| | | * @param thisJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param ret the return value of the method. |
| | | */ |
| | | @AfterReturning(pointcut = "shouldTrace() && tracedMethod() &&" + |
| | | "traceConstructor()", |
| | | @AfterReturning(pointcut = "shouldTrace() && " + |
| | | "(tracedExitMethod() || tracedExitConstructor())", |
| | | returning = "ret") |
| | | public void traceReturn(JoinPoint.StaticPart thisJoinPointStaticPart, |
| | | Object ret) |
| | |
| | | /** |
| | | * AspectJ Implementation. |
| | | * |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param thisJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param ex the exception thrown. |
| | | */ |
| | | @AfterThrowing(pointcut = "shouldTrace() && tracedThrownMethod()", |
| | | throwing = "ex") |
| | | public void traceThrown(JoinPoint.StaticPart thisJoinPointStaticPart, |
| | | Throwable ex) |
| | | { |
| | | LogCategory category = DebugLogCategory.THROWN; |
| | | LogLevel level = DEFAULT_THROWN_LEVEL; |
| | | Signature signature = thisJoinPointStaticPart.getSignature(); |
| | | TraceSettings settings = getSettings(signature.getName()); |
| | | if (level.intValue() >= |
| | | getEffectiveLevel(settings, category).intValue()) |
| | | { |
| | | SourceLocation sl = thisJoinPointStaticPart.getSourceLocation(); |
| | | publish(category, level, signature.toLongString(), sl.toString(), |
| | | null, null , new Object[]{ex}, settings); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * AspectJ Implementation. |
| | | * |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object |
| | | * of the code that contains the |
| | | * debug call. |
| | | * @param thisJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param msg message to format and log. |
| | | */ |
| | | @Around("shouldTrace() && logVerboseMethod() && args(msg)") |
| | | public void traceVerbose(JoinPoint.EnclosingStaticPart |
| | | thisEnclosingJoinPointStaticPart, String msg) |
| | | thisEnclosingJoinPointStaticPart, |
| | | JoinPoint.StaticPart |
| | | thisJoinPointStaticPart, |
| | | String msg) |
| | | { |
| | | LogLevel level = DebugLogLevel.VERBOSE; |
| | | LogCategory category = DebugLogCategory.MESSAGE; |
| | |
| | | if (level.intValue() >= |
| | | getEffectiveLevel(settings, category).intValue()) |
| | | { |
| | | SourceLocation sl = thisEnclosingJoinPointStaticPart.getSourceLocation(); |
| | | SourceLocation sl = thisJoinPointStaticPart.getSourceLocation(); |
| | | publish(category, level, signature.toLongString(), |
| | | sl.toString(), null, msg, null, settings); |
| | | } |
| | |
| | | /** |
| | | * AspectJ Implementation. |
| | | * |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object |
| | | * of the code that contains the |
| | | * debug call. |
| | | * @param thisJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param msg message to format and log. |
| | | * @param msgArgs arguments to place into the format string. |
| | | */ |
| | | @Around("shouldTrace() && logVerboseMethod() && args(msg, msgArgs)") |
| | | public void traceVerbose(JoinPoint.EnclosingStaticPart |
| | | thisEnclosingJoinPointStaticPart, |
| | | JoinPoint.StaticPart |
| | | thisJoinPointStaticPart, |
| | | String msg, Object[] msgArgs) |
| | | { |
| | | LogLevel level = DebugLogLevel.VERBOSE; |
| | |
| | | if (level.intValue() >= |
| | | getEffectiveLevel(settings, category).intValue()) |
| | | { |
| | | SourceLocation sl = thisEnclosingJoinPointStaticPart.getSourceLocation(); |
| | | SourceLocation sl = thisJoinPointStaticPart.getSourceLocation(); |
| | | publish(category, level, signature.toLongString(), |
| | | sl.toString(), null, msg, msgArgs, settings); |
| | | } |
| | |
| | | /** |
| | | * AspectJ Implementation. |
| | | * |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object |
| | | * of the code that contains the |
| | | * debug call. |
| | | * @param thisJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param msg message to format and log. |
| | | */ |
| | | @Around("shouldTrace() && logInfoMethod() && args(msg)") |
| | | public void traceInfo(JoinPoint.EnclosingStaticPart |
| | | thisEnclosingJoinPointStaticPart, String msg) |
| | | thisEnclosingJoinPointStaticPart, |
| | | JoinPoint.StaticPart |
| | | thisJoinPointStaticPart, |
| | | String msg) |
| | | { |
| | | LogLevel level = DebugLogLevel.INFO; |
| | | LogCategory category = DebugLogCategory.MESSAGE; |
| | |
| | | if (level.intValue() >= |
| | | getEffectiveLevel(settings, category).intValue()) |
| | | { |
| | | SourceLocation sl = thisEnclosingJoinPointStaticPart.getSourceLocation(); |
| | | SourceLocation sl = thisJoinPointStaticPart.getSourceLocation(); |
| | | publish(category, level, signature.toLongString(), |
| | | sl.toString(), null, msg, null, settings); |
| | | } |
| | |
| | | /** |
| | | * AspectJ Implementation. |
| | | * |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object |
| | | * of the code that contains the |
| | | * debug call. |
| | | * @param thisJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param msg message to format and log. |
| | | * @param msgArgs arguments to place into the format string. |
| | | */ |
| | | @Around("shouldTrace() && logInfoMethod() && args(msg, msgArgs)") |
| | | public void traceInfo(JoinPoint.EnclosingStaticPart |
| | | thisEnclosingJoinPointStaticPart, |
| | | JoinPoint.StaticPart |
| | | thisJoinPointStaticPart, |
| | | String msg, Object[] msgArgs) |
| | | { |
| | | LogLevel level = DebugLogLevel.INFO; |
| | |
| | | if (level.intValue() >= |
| | | getEffectiveLevel(settings, category).intValue()) |
| | | { |
| | | SourceLocation sl = thisEnclosingJoinPointStaticPart.getSourceLocation(); |
| | | SourceLocation sl = thisJoinPointStaticPart.getSourceLocation(); |
| | | publish(category, level, signature.toLongString(), |
| | | sl.toString(), null, msg, msgArgs, settings); |
| | | } |
| | |
| | | /** |
| | | * AspectJ Implementation. |
| | | * |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object |
| | | * of the code that contains the |
| | | * debug call. |
| | | * @param thisJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param msg message to format and log. |
| | | */ |
| | | @Around("shouldTrace() && logWarningMethod() && args(msg)") |
| | | public void traceWarning(JoinPoint.EnclosingStaticPart |
| | | thisEnclosingJoinPointStaticPart, String msg) |
| | | thisEnclosingJoinPointStaticPart, |
| | | JoinPoint.StaticPart |
| | | thisJoinPointStaticPart, |
| | | String msg) |
| | | |
| | | { |
| | | LogLevel level = DebugLogLevel.WARNING; |
| | |
| | | if (level.intValue() >= |
| | | getEffectiveLevel(settings, category).intValue()) |
| | | { |
| | | SourceLocation sl = thisEnclosingJoinPointStaticPart.getSourceLocation(); |
| | | SourceLocation sl = thisJoinPointStaticPart.getSourceLocation(); |
| | | publish(category, level, signature.toLongString(), |
| | | sl.toString(), null, msg, null, settings); |
| | | } |
| | |
| | | /** |
| | | * AspectJ Implementation. |
| | | * |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object |
| | | * of the code that contains the |
| | | * debug call. |
| | | * @param thisJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param msg message to format and log. |
| | | * @param msgArgs arguments to place into the format string. |
| | | */ |
| | | @Around("shouldTrace() && logWarningMethod() && args(msg, msgArgs)") |
| | | public void traceWarning(JoinPoint.EnclosingStaticPart |
| | | thisEnclosingJoinPointStaticPart, |
| | | JoinPoint.StaticPart |
| | | thisJoinPointStaticPart, |
| | | String msg, Object[] msgArgs) |
| | | { |
| | | LogLevel level = DebugLogLevel.WARNING; |
| | |
| | | if (level.intValue() >= |
| | | getEffectiveLevel(settings, category).intValue()) |
| | | { |
| | | SourceLocation sl = thisEnclosingJoinPointStaticPart.getSourceLocation(); |
| | | SourceLocation sl = thisJoinPointStaticPart.getSourceLocation(); |
| | | publish(category, level, signature.toLongString(), |
| | | sl.toString(), null, msg, msgArgs, settings); |
| | | } |
| | |
| | | /** |
| | | * AspectJ Implementation. |
| | | * |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object |
| | | * of the code that contains the |
| | | * debug call. |
| | | * @param thisJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param msg message to format and log. |
| | | */ |
| | | @Around("shouldTrace() && logErrorMethod() && args(msg)") |
| | | public void traceError(JoinPoint.EnclosingStaticPart |
| | | thisEnclosingJoinPointStaticPart, String msg) |
| | | thisEnclosingJoinPointStaticPart, |
| | | JoinPoint.StaticPart |
| | | thisJoinPointStaticPart, |
| | | String msg) |
| | | |
| | | { |
| | | LogLevel level = DebugLogLevel.ERROR; |
| | |
| | | if (level.intValue() >= |
| | | getEffectiveLevel(settings, category).intValue()) |
| | | { |
| | | SourceLocation sl = thisEnclosingJoinPointStaticPart.getSourceLocation(); |
| | | SourceLocation sl = thisJoinPointStaticPart.getSourceLocation(); |
| | | publish(category, level, signature.toLongString(), |
| | | sl.toString(), null, msg, null, settings); |
| | | } |
| | |
| | | /** |
| | | * AspectJ Implementation. |
| | | * |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object |
| | | * of the code that contains the |
| | | * debug call. |
| | | * @param thisJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param msg message to format and log. |
| | | * @param msgArgs arguments to place into the format string. |
| | | */ |
| | | @Around("shouldTrace() && logErrorMethod() && args(msg, msgArgs)") |
| | | public void traceError(JoinPoint.EnclosingStaticPart |
| | | thisEnclosingJoinPointStaticPart, |
| | | JoinPoint.StaticPart |
| | | thisJoinPointStaticPart, |
| | | String msg, Object[] msgArgs) |
| | | { |
| | | LogLevel level = DebugLogLevel.ERROR; |
| | |
| | | if (level.intValue() >= |
| | | getEffectiveLevel(settings, category).intValue()) |
| | | { |
| | | SourceLocation sl = thisEnclosingJoinPointStaticPart.getSourceLocation(); |
| | | SourceLocation sl = thisJoinPointStaticPart.getSourceLocation(); |
| | | publish(category, level, signature.toLongString(), |
| | | sl.toString(), null, msg, msgArgs, settings); |
| | | } |
| | |
| | | /** |
| | | * AspectJ Implementation. |
| | | * |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object |
| | | * of the code that contains the |
| | | * debug call. |
| | | * @param thisJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param level the level of the log message. |
| | | * @param msg message to format and log. |
| | | */ |
| | | @Around("shouldTrace() && logMessageMethod() && args(level, msg)") |
| | | public void traceMessage(JoinPoint.EnclosingStaticPart |
| | | thisEnclosingJoinPointStaticPart, |
| | | JoinPoint.StaticPart |
| | | thisJoinPointStaticPart, |
| | | LogLevel level, String msg) |
| | | { |
| | | LogCategory category = DebugLogCategory.MESSAGE; |
| | |
| | | if (level.intValue() >= |
| | | getEffectiveLevel(settings, category).intValue()) |
| | | { |
| | | SourceLocation sl = thisEnclosingJoinPointStaticPart.getSourceLocation(); |
| | | SourceLocation sl = thisJoinPointStaticPart.getSourceLocation(); |
| | | publish(category, level, signature.toLongString(), sl.toString(), |
| | | null, msg, null, settings); |
| | | } |
| | |
| | | /** |
| | | * AspectJ Implementation. |
| | | * |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object |
| | | * of the code that contains the |
| | | * debug call. |
| | | * @param thisJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param level the level of the log message. |
| | | * @param msg message to format and log. |
| | | * @param msgArgs arguments to place into the format string. |
| | |
| | | @Around("shouldTrace() && logMessageMethod() && args(level, msg, msgArgs)") |
| | | public void traceMessage(JoinPoint.EnclosingStaticPart |
| | | thisEnclosingJoinPointStaticPart, |
| | | JoinPoint.StaticPart |
| | | thisJoinPointStaticPart, |
| | | LogLevel level, String msg, Object... msgArgs) |
| | | { |
| | | LogCategory category = DebugLogCategory.MESSAGE; |
| | |
| | | if (level.intValue() >= |
| | | getEffectiveLevel(settings, category).intValue()) |
| | | { |
| | | SourceLocation sl = thisEnclosingJoinPointStaticPart.getSourceLocation(); |
| | | SourceLocation sl = thisJoinPointStaticPart.getSourceLocation(); |
| | | publish(category, level, signature.toLongString(), sl.toString(), |
| | | null, msg, msgArgs, settings); |
| | | } |
| | |
| | | /** |
| | | * AspectJ Implementation. |
| | | * |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object |
| | | * of the code that contains the |
| | | * debug call. |
| | | * @param thisJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param level the level of the log message. |
| | | * @param ex the exception thrown. |
| | | */ |
| | | @Around("shouldTrace() && logThrownMethod() && args(level, ex)") |
| | | public void traceThrown(JoinPoint.EnclosingStaticPart |
| | | thisEnclosingJoinPointStaticPart, |
| | | JoinPoint.StaticPart |
| | | thisJoinPointStaticPart, |
| | | LogLevel level, Throwable ex) |
| | | { |
| | | LogCategory category = DebugLogCategory.THROWN; |
| | |
| | | if (level.intValue() >= |
| | | getEffectiveLevel(settings, category).intValue()) |
| | | { |
| | | SourceLocation sl = thisEnclosingJoinPointStaticPart.getSourceLocation(); |
| | | SourceLocation sl = thisJoinPointStaticPart.getSourceLocation(); |
| | | publish(category, level, signature.toLongString(), sl.toString(), |
| | | null, null , new Object[]{ex}, settings); |
| | | } |
| | |
| | | /** |
| | | * AspectJ Implementation. |
| | | * |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object |
| | | * of the code that contains the |
| | | * debug call. |
| | | * @param thisJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param level the level of the log message. |
| | | * @param ex the exception caught. |
| | | */ |
| | | @Around("shouldTrace() && logCaughtMethod() && args(level, ex)") |
| | | public void traceCaught(JoinPoint.EnclosingStaticPart |
| | | thisEnclosingJoinPointStaticPart, |
| | | JoinPoint.StaticPart |
| | | thisJoinPointStaticPart, |
| | | LogLevel level, Throwable ex) |
| | | { |
| | | LogCategory category = DebugLogCategory.CAUGHT; |
| | |
| | | if (level.intValue() >= |
| | | getEffectiveLevel(settings, category).intValue()) |
| | | { |
| | | SourceLocation sl = thisEnclosingJoinPointStaticPart.getSourceLocation(); |
| | | SourceLocation sl = thisJoinPointStaticPart.getSourceLocation(); |
| | | publish(category, level, signature.toLongString(), sl.toString(), |
| | | null, null , new Object[]{ex}, settings); |
| | | } |
| | |
| | | /** |
| | | * AspectJ Implementation. |
| | | * |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object |
| | | * of the code that contains the |
| | | * debug call. |
| | | * @param thisJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param level the level of the log message. |
| | | * @param status status of the JE operation. |
| | | * @param database the database handle. |
| | |
| | | "database, txn, key, data)") |
| | | public void traceJEAccess(JoinPoint.EnclosingStaticPart |
| | | thisEnclosingJoinPointStaticPart, |
| | | JoinPoint.StaticPart |
| | | thisJoinPointStaticPart, |
| | | LogLevel level, OperationStatus status, |
| | | Database database, Transaction txn, |
| | | DatabaseEntry key, DatabaseEntry data) |
| | |
| | | builder.append(" txnid=none"); |
| | | } |
| | | |
| | | // If the operation was successful we log the same common information |
| | | // plus the key and data under category DATABASE_READ or DATABASE_WRITE |
| | | if (status == OperationStatus.SUCCESS) |
| | | builder.append(ServerConstants.EOL); |
| | | if(key != null) |
| | | { |
| | | builder.append(ServerConstants.EOL); |
| | | builder.append(" key:"); |
| | | builder.append("key:"); |
| | | builder.append(ServerConstants.EOL); |
| | | StaticUtils.byteArrayToHexPlusAscii(builder, key.getData(), 4); |
| | | if (data != null) |
| | | { |
| | | builder.append("data(len="); |
| | | builder.append(data.getSize()); |
| | | builder.append("):"); |
| | | builder.append(ServerConstants.EOL); |
| | | StaticUtils.byteArrayToHexPlusAscii(builder, data.getData(), 4); |
| | | } |
| | | } |
| | | |
| | | // If the operation was successful we log the same common information |
| | | // plus the data |
| | | if (status == OperationStatus.SUCCESS && data != null) |
| | | { |
| | | |
| | | builder.append("data(len="); |
| | | builder.append(data.getSize()); |
| | | builder.append("):"); |
| | | builder.append(ServerConstants.EOL); |
| | | StaticUtils.byteArrayToHexPlusAscii(builder, data.getData(), 4); |
| | | |
| | | } |
| | | |
| | | |
| | | SourceLocation sl = thisEnclosingJoinPointStaticPart.getSourceLocation(); |
| | | SourceLocation sl = thisJoinPointStaticPart.getSourceLocation(); |
| | | publish(category, level, signature.toLongString(), sl.toString(), null, |
| | | builder.toString(), null, settings); |
| | | } |
| | |
| | | |
| | | /** |
| | | * AspectJ Implementation. |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object |
| | | * of the code that contains the |
| | | * debug call. |
| | | * @param thisJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param level the level of the log message. |
| | | * @param data the data to dump. |
| | | */ |
| | | @Around("shouldTrace() && logDataMethod() && args(level, data)") |
| | | public void traceData(JoinPoint.EnclosingStaticPart |
| | | thisEnclosingJoinPointStaticPart, |
| | | JoinPoint.StaticPart |
| | | thisJoinPointStaticPart, |
| | | LogLevel level, byte[] data) |
| | | { |
| | | LogCategory category = DebugLogCategory.DATA; |
| | |
| | | builder.append(ServerConstants.EOL); |
| | | StaticUtils.byteArrayToHexPlusAscii(builder, data, 4); |
| | | SourceLocation sl = |
| | | thisEnclosingJoinPointStaticPart.getSourceLocation(); |
| | | thisJoinPointStaticPart.getSourceLocation(); |
| | | publish(category, level, signature.toLongString(), sl.toString(), null, |
| | | builder.toString(), null, settings); |
| | | } |
| | |
| | | /** |
| | | * AspectJ Implementation. |
| | | * |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object |
| | | * of the code that contains the |
| | | * debug call. |
| | | * @param thisJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param level the level of the log message. |
| | | * @param element the protocol element to dump. |
| | | */ |
| | | @Around("shouldTrace() && logProtocolElementMethod() && args(level, element)") |
| | | public void traceProtocolElement(JoinPoint.EnclosingStaticPart |
| | | thisEnclosingJoinPointStaticPart, |
| | | JoinPoint.StaticPart |
| | | thisJoinPointStaticPart, |
| | | LogLevel level, ProtocolElement element) |
| | | { |
| | | LogCategory category = DebugLogCategory.PROTOCOL; |
| | |
| | | builder.append(ServerConstants.EOL); |
| | | element.toString(builder, 4); |
| | | SourceLocation sl = |
| | | thisEnclosingJoinPointStaticPart.getSourceLocation(); |
| | | thisJoinPointStaticPart.getSourceLocation(); |
| | | publish(category, level, signature.toLongString(), sl.toString(), null, |
| | | builder.toString(), null, settings); |
| | | } |
| | |
| | | /** |
| | | * AspectJ Implementation. |
| | | * |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param thisEnclosingJoinPointStaticPart the JoinPoint reflection object |
| | | * of the code that contains the |
| | | * debug call. |
| | | * @param thisJoinPointStaticPart the JoinPoint reflection object. |
| | | * @param level the level of the log message. |
| | | * @param buffer the data to dump. |
| | | */ |
| | | @Around("shouldTrace() && logDataMethod() && args(level, buffer)") |
| | | public void traceData(JoinPoint.EnclosingStaticPart |
| | | thisEnclosingJoinPointStaticPart, |
| | | JoinPoint.StaticPart |
| | | thisJoinPointStaticPart, |
| | | LogLevel level, ByteBuffer buffer) |
| | | { |
| | | LogCategory category = DebugLogCategory.DATA; |
| | |
| | | builder.append(ServerConstants.EOL); |
| | | StaticUtils.byteArrayToHexPlusAscii(builder, data, 4); |
| | | SourceLocation sl = |
| | | thisEnclosingJoinPointStaticPart.getSourceLocation(); |
| | | thisJoinPointStaticPart.getSourceLocation(); |
| | | publish(category, level, signature.toLongString(), sl.toString(), null, |
| | | builder.toString(), null, settings); |
| | | } |
| | |
| | | { |
| | | int stackDepth = 0; |
| | | |
| | | if(DebugLogCategory.ENTER.equals(category)) |
| | | if (DebugLogCategory.ENTER.equals(category) || |
| | | DebugLogCategory.CONSTRUCTOR.equals(category)) |
| | | { |
| | | if (settings.noArgs) |
| | | if(settings.noArgs) |
| | | { |
| | | msgArgs = null; |
| | | } |
| | |
| | | { |
| | | msg = buildDefaultEntryMessage(msgArgs.length); |
| | | } |
| | | |
| | | stackDepth = settings.stackDepth; |
| | | } |
| | | if(DebugLogCategory.EXIT.equals(category)) |
| | | |
| | | else if(DebugLogCategory.EXIT.equals(category)) |
| | | { |
| | | if (settings.noRetVal) |
| | | if(settings.noRetVal) |
| | | { |
| | | msgArgs = null; |
| | | } |
| | |
| | | msg = "returned={%s}"; |
| | | } |
| | | } |
| | | if(DebugLogCategory.THROWN.equals(category)) |
| | | |
| | | else if(DebugLogCategory.THROWN.equals(category)) |
| | | { |
| | | if (msg == null) |
| | | if(msg == null) |
| | | { |
| | | msg = "threw={%s}"; |
| | | } |
| | | stackDepth = settings.stackDepth; |
| | | } |
| | | |
| | | else if(DebugLogCategory.CAUGHT.equals(category)) |
| | | { |
| | | if(msg == null) |
| | | { |
| | | msg = "caught={%s}"; |
| | | } |
| | | } |
| | | |
| | | if (msg != null && msgArgs != null) |
| | | { |
| | | msg = String.format(msg, msgArgs); |
| | | msg = msgFormatter.format(msg, msgArgs); |
| | | } |
| | | |
| | | |
| | |
| | | record.setSignature(method); |
| | | record.setSourceLocation(srcLocation); |
| | | |
| | | Thread thread = Thread.currentThread(); |
| | | if(thread instanceof DirectoryThread) |
| | | { |
| | | record.setThreadProperties( |
| | | ((DirectoryThread)thread).getDebugProperties()); |
| | | } |
| | | |
| | | //Stack trace applies only to entry and thrown exception messages. |
| | | if(DebugLogCategory.ENTER.equals(category) || |
| | | DebugLogCategory.THROWN.equals(category)) |
| | | { |
| | | stackDepth = settings.stackDepth; |
| | | } |
| | | |
| | | // Inject a stack trace if requested |
| | | if (stackDepth > 0) { |
| | | |
| | | //Generate a dummy exception to get stack trace if necessary |
| | | Throwable t; |
| | | if(!DebugLogCategory.THROWN.equals(category) || msgArgs == null |
| | | || msgArgs[0] == null) |
| | | { |
| | | t= new NullPointerException(); |
| | | } |
| | | else |
| | | { |
| | | t = (Throwable)msgArgs[0]; |
| | | } |
| | | |
| | | Throwable t= new NullPointerException(); |
| | | String stack= |
| | | DebugStackTraceFormatter.formatStackTrace(t, |
| | | DebugStackTraceFormatter.SMART_FRAME_FILTER, |
| | |
| | | |
| | | /** |
| | | * Update the settings for this tracer. |
| | | * |
| | | * @param config the new trace configuration. |
| | | */ |
| | | protected void updateSettings() |
| | | protected void updateSettings(DebugConfiguration config) |
| | | { |
| | | synchronized (this) |
| | | { |
| | | this.settings = |
| | | logger.getConfiguration().getTraceSettings(className); |
| | | this.methodSettings = |
| | | logger.getConfiguration().getMethodSettings(className); |
| | | this.settings = config.getTraceSettings(className); |
| | | this.methodSettings = config.getMethodSettings(className); |
| | | } |
| | | } |
| | | |
| | |
| | | return getEffectiveLevel(settings, category); |
| | | } |
| | | |
| | | /** |
| | | * 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 not be weaved by AspectJ with |
| | | * debug logging statements when an exception is thrown from the method. |
| | | */ |
| | | public @interface TraceThrown {} |
| | | |
| | | } |