# audit_trail v0.1.0 - Table of Contents

> Reusable structured audit logging, DB change tracking, and crash reporting for Elixir/Phoenix apps

## Pages

- [AuditTrail](readme.md)

## Modules

- [AuditTrail](AuditTrail.md): Reusable structured audit logging, DB change tracking, and crash reporting.
- [AuditTrail.ActorStore](AuditTrail.ActorStore.md)
- [AuditTrail.Adapter](AuditTrail.Adapter.md): Behaviour for AuditTrail storage backends.
- [AuditTrail.Adapters.Loki](AuditTrail.Adapters.Loki.md): Storage adapter that ships logs to Grafana Loki via HTTP.
- [AuditTrail.Adapters.Postgres](AuditTrail.Adapters.Postgres.md): Storage adapter that persists audit logs to a PostgreSQL table.
- [AuditTrail.Adapters.SMTP](AuditTrail.Adapters.SMTP.md): Raw SMTP adapter using Swoosh's SMTP adapter directly.
Does not require a host-app Mailer module — reads SMTP config from AuditTrail config.
- [AuditTrail.Adapters.Swoosh](AuditTrail.Adapters.Swoosh.md): Swoosh mailer adapter. Requires the host app to have Swoosh configured.
- [AuditTrail.Adapters.Test](AuditTrail.Adapters.Test.md): In-memory storage adapter for tests. Accumulates every pushed log in an
ETS table instead of shipping it anywhere, so a test suite can assert on
what got logged without a running Loki/Postgres.
- [AuditTrail.Adapters.TimescaleDB](AuditTrail.Adapters.TimescaleDB.md): Storage adapter for TimescaleDB — PostgreSQL with automatic time partitioning.
- [AuditTrail.Application](AuditTrail.Application.md)
- [AuditTrail.Buffer](AuditTrail.Buffer.md)
- [AuditTrail.Config](AuditTrail.Config.md)
- [AuditTrail.ControllerAudit](AuditTrail.ControllerAudit.md): Plug for declarative controller-level audit logging.
- [AuditTrail.CrashReporter](AuditTrail.CrashReporter.md): OTP :logger handler that intercepts error/crash events and routes them
through AuditTrail.Deduplicator → AuditTrail.Notifier.
- [AuditTrail.DeadLetter](AuditTrail.DeadLetter.md)
- [AuditTrail.Deduplicator](AuditTrail.Deduplicator.md)
- [AuditTrail.Diff](AuditTrail.Diff.md): Computes field-level diffs from Ecto changesets.
- [AuditTrail.LiveViewAudit](AuditTrail.LiveViewAudit.md): Declarative audit logging for LiveView `handle_event/3`, mirroring
`AuditTrail.ControllerAudit`'s write/read config style for controllers.
- [AuditTrail.Logger](AuditTrail.Logger.md)
- [AuditTrail.Notifier](AuditTrail.Notifier.md)
- [AuditTrail.Plug](AuditTrail.Plug.md): Phoenix plug that sets the actor context and logs every HTTP request.
- [AuditTrail.Reader](AuditTrail.Reader.md): Query audit logs from Loki.
- [AuditTrail.RepoWatcher](AuditTrail.RepoWatcher.md): Add to your Ecto.Repo (after `use Ecto.Repo`) to enable automatic
schema-level change tracking for any schema that uses `AuditTrail.Schema`.
- [AuditTrail.Sanitizer](AuditTrail.Sanitizer.md): Runs on every payload in `AuditTrail.Buffer` right before it ships
— the one choke point every entry point (`emit/2`, `monitor/4`, schema-level
`Diff`, `ControllerAudit`) funnels through. Besides making values
JSON-safe, it redacts any map value whose key matches
`AuditTrail.Config.sensitive_fields/0` (case-insensitively, atom or string
keys, at any nesting depth) — so a sensitive field slipping into a
`track: :all` schema diff, or into `monitor`/`emit`'s `original_record:`/
`params:` diffing, still gets caught here even if the call site forgot to
filter it out itself. `ControllerAudit` still does its own upfront
`Map.drop/2` for the same field list — this is the backstop for
everything else.

- [AuditTrail.Schema](AuditTrail.Schema.md): Marks an Ecto schema for automatic field-level change tracking.
- [AuditTrail.Shipper](AuditTrail.Shipper.md)
- [AuditTrail.Task](AuditTrail.Task.md): Drop-in wrappers for Task that propagate the actor context to child processes.
- [AuditTrail.TenantStore](AuditTrail.TenantStore.md): Process-dictionary store for the current tenant/org id, mirroring
`AuditTrail.ActorStore`. Set once per request/job with `AuditTrail.set_tenant/1`;
every subsequent `emit`/`monitor`/schema-tracked Repo call in the same
process is tagged with it automatically.

- [AuditTrail.Test](AuditTrail.Test.md): Test helpers for asserting on audit events, meant to be used together
with `AuditTrail.Adapters.Test` (see its moduledoc for setup).

## Mix Tasks

- [mix audit_trail.gen.migration](Mix.Tasks.AuditTrail.Gen.Migration.md): Generates an Ecto migration for the `audit_logs` table.

