[][src]Crate sql_audit

The companion library to sql-audit-cli, though you can just use this instead if you'd like to generate audit programmatically.

Limitations

  1. Currently this lib only knows how to use sqlx, so you must use it too.

Tour

  • generate_audit is the programmatic equivalent of running sql-audit-cli.
  • query_audit lets you query the audit table... currently only supports querying all records for a table.
  • set_local_app_user sets the value to fill into app_user in the audit table for the duration of the current transaction.
  • set_local_request_id sets the value to fill into request_id in the audit table for the duration of the current transaction.

Structs

AuditRecord

A structure representing a single row of the audit table.

Constants

APP_USER_SETTING

A constant for the setting used to record app_user in the audit table.

REQUEST_ID_SETTING

A constant for the setting used to record request_id in the audit table.

Functions

generate_audit

Generate the audit infrastructure for the database that the passed pool connects to. This function will:

query_audit

Get all the audit records for a specific table.

set_local_app_user

Set a value to be recorded in the app_user column of the audit table. Only valid for the current transaction and does nothing if there is no current transaction.

set_local_request_id

Set a value to be recorded in the request_id column of the audit table. Only valid for the current transaction and does nothing if there is no current transaction.