A pure ARO plugin that provides event handlers for audit logging.
This plugin demonstrates how to create a plugin using only ARO files (no native code). It provides event handlers that automatically log domain events when they are emitted by the application.
aro add https://github.com/arolang/plugin-aro-auditlog.git| Event Type | Handler Name | Description |
|---|---|---|
UserCreated |
Log User Events | Logs when a user is created |
OrderPlaced |
Log Order Events | Logs when an order is placed |
PaymentReceived |
Log Payment Events | Logs when a payment is received |
Once installed, the handlers automatically respond to matching events:
(Application-Start: My App) {
(* Emit an event - the plugin handler will automatically respond *)
<Emit> a <UserCreated: event> with {
user: { id: "123", name: "Alice" }
}.
<Return> an <OK: status> for the <startup>.
}
Output:
[Log User Events] [AUDIT] UserCreated: User created
- The plugin's
plugin.yamldeclares it providesaro-files - When loaded, the
.arofiles infeatures/are compiled - Feature sets with business activity
<EventName> Handlerbecome event handlers - When matching events are emitted, the handlers execute automatically
plugin-aro-auditlog/
├── plugin.yaml # Plugin manifest
├── README.md # This file
└── features/
└── audit-handlers.aro # Event handler definitions
To add handlers for additional event types, edit features/audit-handlers.aro:
(Log Custom Events: MyCustomEvent Handler) {
<Extract> the <data> from the <event: data>.
<Log> "[AUDIT] MyCustomEvent received" to the <console>.
<Return> an <OK: status> for the <audit>.
}
MIT