Annotation Interface AuditLog


@Documented @Retention(RUNTIME) @Target(METHOD) public @interface AuditLog
Records method invocations to an audit trail.

Usage


 @AuditLog(action = "user.approve")
 public void approveUser(String userId) { }

 @AuditLog(action = "config.change", includeArgs = true)
 public void updateConfig(String key, String value) { }
 

An action's own @AuditLog applies, else the first found on a method it overrides, walking the target's class and each superclass up the chain, then the interfaces of those classes from the topmost superclass's down to the target class's own, each class's interfaces in declaration order, depth-first through the interfaces each extends, skipping an interface already walked. An override that does not repeat it is therefore still audited, once.

Since:
0.3.0
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    Action name for the audit entry (e.g., "user.approve", "config.change").
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    Whether to include method arguments in the audit record.
    boolean
    Whether to include the return value in the audit record.
  • Element Details

    • action

      String action
      Action name for the audit entry (e.g., "user.approve", "config.change").
      Returns:
      action name
    • includeArgs

      boolean includeArgs
      Whether to include method arguments in the audit record.
      Returns:
      true to log args (default: false)
      Default:
      false
    • includeResult

      boolean includeResult
      Whether to include the return value in the audit record.
      Returns:
      true to log result (default: false)
      Default:
      false