WP Manifestindependent plugin directory
manifest / ai / ai-client-logger

AI Client Logger

Logs WordPress AI Client interactions with metadata, token usage, and audit trail.

by Solutions Engineering · github.com/ross-mulcahy/ai-client-logger · website

0stars
0forks

Install

No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:

wp plugin install https://github.com/ross-mulcahy/ai-client-logger/archive/refs/heads/main.zip

A WordPress plugin that logs AI Client interactions with metadata, token usage tracking, and an audit trail.

Requirements

  • WordPress 6.9+ with the AI Experiments plugin, or WordPress 7.0+
  • PHP 8.1+

Installation

  1. Clone or copy the plugin to wp-content/plugins/ai-client-logger/
  2. Run npm install && npm run build
  3. Activate the plugin in WordPress admin

Features

Automatic AI Call Logging

Every AI Client interaction is automatically logged with:

  • User who triggered the call
  • AI provider and model used
  • Token usage (prompt, completion, thought, total)
  • Request duration
  • Success/error status with error codes
  • Raw prompt and response text (configurable)

Admin Settings

Settings > AI Logger — configure:

  • Enable/disable logging
  • Log prompts and responses (can be disabled for privacy)
  • IP address capture (off by default for GDPR)
  • Retention period (1 day to forever)
  • Dashboard widget settings
  • Excluded user roles and actions

Log Viewer

Tools > AI Logs — browse, filter, sort, and export log entries:

  • Filter by provider, action, status, user
  • Sort by any column
  • Bulk delete or CSV export

REST API

Method Route Permission
GET /wp/v2/ai-logs manage_ai_logs
GET /wp/v2/ai-logs/{id} read_ai_log_entries
DELETE /wp/v2/ai-logs/{id} delete_ai_log_entries
GET /ai-client-logger/v1/stats manage_ai_logs
GET /ai-client-logger/v1/stats/user/{id} manage_ai_logs

Logs are immutable — no POST/PUT/PATCH endpoints.

WP-CLI Commands

wp ai-logger list [--per-page=<n>] [--provider=<slug>] [--status=<status>] [--format=table|json|csv]
wp ai-logger stats [--period=<7days|30days|90days>] [--group-by=<date|provider|model>]
wp ai-logger purge [--days=<n>] [--dry-run]
wp ai-logger export --output=<file> [--provider=<slug>] [--after=<date>] [--before=<date>]

Dashboard Widget

A Chart.js line chart on the WordPress dashboard showing daily AI call volume and token usage.

Extensible Logger Architecture

Add custom log destinations (Splunk, Datadog, webhooks) without modifying plugin code:

add_action( 'wp_ai_logger/loggers', function( $registry ) {
    $registry->add( new My_Plugin\SplunkLogger( ... ) );
} );

Hooks & Filters

Actions

Hook Description
wp_ai_logger/loggers Register additional loggers
wp_ai_logger/before_log Before a log entry is written
wp_ai_logger/after_log After successful log entry creation
wp_ai_logger/log_error When a log entry fails to save
wp_ai_logger/before_purge Before the retention purge
wp_ai_logger/after_purge After purge completes

Filters

Filter Description
wp_ai_logger/should_log Suppress logging for specific calls
wp_ai_logger/log_entry_args Modify post args before saving
wp_ai_logger/retention_days Override retention at runtime
wp_ai_logger/sensitive_meta_keys Extend sensitive fields list
wp_ai_logger/stats_cache_ttl Override stats cache TTL
wp_ai_logger/export_columns Modify CSV export columns

Permissions

Capability Roles
manage_ai_logs Administrator
read_ai_log_entries Administrator, Editor
read_private_ai_log_entries Administrator
delete_ai_log_entries Administrator

Development

composer install
npm install
npm run build        # Production build
npm run start        # Development watch mode
npm run lint:js      # Lint JavaScript
npm run lint:css     # Lint stylesheets
./vendor/bin/phpunit --testsuite unit  # Run unit tests
./bin/build-plugin-zip.sh              # Build a WordPress.org-ready release zip

License

GPL-2.0-or-later