|
2 | 2 |
|
3 | 3 | ## Table of Contents |
4 | 4 |
|
5 | | -@TODO - Regenerate |
6 | | - |
7 | | -- [Overview](#overview) |
8 | | -- [Getting Started](#getting-started) |
9 | | -- [Features](#features) |
10 | | -- [Usage](#usage) |
| 5 | +- [Project Structure](#project-structure) |
| 6 | +- [Key Features](#key-features) |
| 7 | +- [Installation](#installation) |
11 | 8 | - [Configuration](#configuration) |
12 | | -- [Admin & Settings](#admin--settings) |
13 | | -- [Extending the Functionality](#extending-the-functionality) |
14 | | -- [Testing](#testing) |
| 9 | +- [Admin Interface](#admin-interface) |
| 10 | +- [Uninstallation and Data Cleanup](#uninstallation-and-data-cleanup) |
| 11 | +- [How‑to Guides](#how‑to-guides) |
| 12 | +- [Reference](#reference) |
15 | 13 |
|
16 | 14 | --- |
17 | 15 |
|
@@ -47,32 +45,43 @@ wpgraphql-logging/ |
47 | 45 |
|
48 | 46 | ## Key Features |
49 | 47 |
|
50 | | -@TODO |
51 | | - |
52 | | -- **Query event lifecycle logging** |
| 48 | +- **End-to-end GraphQL lifecycle logging** |
53 | 49 | - **Pre Request** (`do_graphql_request`): captures `query`, `variables`, `operation_name`. |
54 | | - - **Before Execution** (`graphql_before_execute`): includes a snapshot of request `params`. |
55 | | - - **Before Response Returned** (`graphql_return_response`): inspects `response` and automatically upgrades level to Error when GraphQL `errors` are present (adds `errors` to context when found). |
| 50 | + - **Before Execution** (`graphql_before_execute`): snapshots request `params`. |
| 51 | + - **Before Response Returned** (`graphql_return_response`): inspects `response`; auto-elevates level to Error when GraphQL `errors` are present (adds `errors` to context). |
56 | 52 |
|
57 | | -- **Built-in pub/sub event bus** |
58 | | - - In-memory event manager with priorities: `subscribe(event, listener, priority)` and `publish(event, payload)`. |
59 | | - - Transform pipeline: `transform(event, payload)` lets you mutate `context` and `level` before logging/publishing. |
| 53 | +- **Developer-friendly pub/sub and transform system** |
| 54 | + - Programmatic API: `Plugin::on($event, $listener)`, `Plugin::transform($event, $callable)`, `Plugin::emit($event, $payload)`. |
| 55 | + - Prioritized execution: lower priority runs earlier for both subscribers and transforms. |
60 | 56 | - WordPress bridges: actions `wpgraphql_logging_event_{event}` and filters `wpgraphql_logging_filter_{event}` to integrate with standard hooks. |
| 57 | + - Safe-by-default: exceptions in listeners/transforms are caught and logged; they do not break the pipeline. |
| 58 | + - See: Reference › Events (`docs/reference/events.md`) and How‑to guides (`docs/how-to/events_pub_sub.md`, `docs/how-to/events_add_context.md`). |
| 59 | + |
| 60 | +- **Extensible Monolog pipeline** |
| 61 | + - Default handler: `WordPressDatabaseHandler` stores logs in `{$wpdb->prefix}wpgraphql_logging`. |
| 62 | + - Add handlers via filter `wpgraphql_logging_default_handlers` (e.g., file, Slack, HTTP, etc.). |
| 63 | + - Add processors via filter `wpgraphql_logging_default_processors` (e.g., enrich records with user/site data). |
| 64 | + - Customize `default_context` via `wpgraphql_logging_default_context`. |
| 65 | + - Use `LoggerService::get_instance()` to build custom channels, handlers, processors. |
61 | 66 |
|
62 | | -- **Monolog-powered logging pipeline** |
63 | | - - Default handler: stores logs in a WordPress table (`{$wpdb->prefix}wpgraphql_logging`). |
| 67 | +- **Configurable rule-based logging** |
| 68 | + - Built-in rules: enabled toggle, IP restrictions, exclude queries, sampling rate, null query guard, response logging toggle. |
| 69 | + - All rules are orchestrated by a `RuleManager` ensuring logs only emit when all rules pass. |
| 70 | + - Extend rules: hook `wpgraphql_logging_rule_manager` to add custom `LoggingRuleInterface` implementations. |
64 | 71 |
|
65 | 72 | - **Automated data management** |
66 | | - - **Daily cleanup scheduler**: Automatically removes old logs based on retention settings. |
67 | | - - **Configurable retention period**: Set how many days to keep log data (default: 30 days). |
68 | | - - **Manual cleanup**: Admin interface to trigger immediate cleanup of old logs. |
69 | | - - **Data sanitization**: Remove sensitive fields from logged data for privacy compliance. |
| 73 | + - **Daily cleanup scheduler**: removes old logs based on retention. |
| 74 | + - **Configurable retention period**: choose days to keep (default 30). |
| 75 | + - **Manual cleanup**: trigger from the admin UI. |
| 76 | + - **Data sanitization**: built-in `DataSanitizationProcessor` removes/anonymizes/truncates sensitive fields with recommended or custom rules. |
70 | 77 |
|
71 | | -- **Simple developer API** |
72 | | - - `Plugin::on()` to subscribe, `Plugin::emit()` to publish, `Plugin::transform()` to modify payloads. |
| 78 | +- **Admin UI for operations** |
| 79 | + - Logs list view with filters (level, date range) and CSV export. |
| 80 | + - Bulk delete actions and visibility controls. |
73 | 81 |
|
74 | | -- **Safe-by-default listeners/transforms** |
75 | | - - Exceptions in listeners/transforms are caught and logged without breaking the pipeline. |
| 82 | +- **Composable and testable architecture** |
| 83 | + - Clear separation: Events bus, Logger service, Rules, Processors, Handlers. |
| 84 | + - Designed for extension via interfaces, filters, and helper APIs. |
76 | 85 |
|
77 | 86 | --- |
78 | 87 |
|
@@ -172,29 +181,22 @@ define( 'WP_GRAPHQL_LOGGING_UNINSTALL_PLUGIN', true ); |
172 | 181 | > **Data Loss Warning**: When `WP_GRAPHQL_LOGGING_UNINSTALL_PLUGIN` is defined as `true`, deactivating the plugin will permanently delete all logged data and drop the plugin's database tables. This action is irreversible. |
173 | 182 |
|
174 | 183 |
|
175 | | -## Reference |
176 | | - |
177 | | -The plugin is developer focussed and can be extended in multiple ways. |
178 | | - |
179 | | -## Admin - (admin configuration, view and functionality) |
| 184 | +## How‑to Guides |
180 | 185 |
|
181 | | -- [Actions/Filters](reference/admin.md) |
| 186 | +### Admin |
182 | 187 | - [How to add a new Settings tab to WPGraphQL Logging](how-to/admin_add_new_tab.md) |
183 | 188 | - [How to add a new field to an existing tab and query it](how-to/admin_add_fields.md) |
184 | 189 | - [How to add a new column to the Logs admin grid](how-to/admin_add_view_column.md) |
185 | 190 |
|
| 191 | +### Events |
| 192 | +- [How to add context data to a logged WPGraphQL event](how-to/events_add_context.md) |
| 193 | +- [How to use the WPGraphQL Logging events pub/sub system](how-to/events_pub_sub.md) |
186 | 194 |
|
187 | | -@TODO - How to guides |
188 | | - |
189 | | -## Events - (Event Management, Adding and extending events, Using the pub/sub) |
190 | | -- [Actions/Filters](reference/events.md) |
191 | | - |
192 | | -@TODO - How to guides |
193 | | - |
194 | | -## Logging - (Logging Service, Monolog Handlers & Processors, Rule Manager, Data Management) |
195 | | -- [Actions/Filters](reference/logging.md) |
196 | | - |
197 | | -@TODO - How to guides |
| 195 | +### Logging |
| 196 | +- @TODO — add how‑to guides for LoggerService, handlers, processors, rules |
198 | 197 |
|
| 198 | +## Reference |
199 | 199 |
|
200 | | ----- |
| 200 | +- Admin: [Actions/Filters](reference/admin.md) |
| 201 | +- Events: [Actions/Filters](reference/events.md) |
| 202 | +- Logging: [Actions/Filters](reference/logging.md) |
0 commit comments