WP-CLI commands

Simple History comes with some useful WP-CLI commands. With them you can for example view and search the events log.

Commands overview

The current WP-CLI commands for interacting with the events log are as follows:

  • wp simple-history list to list events.
  • wp simple-history event list to list events (alias of first command)
  • wp simple-history event get to get details about a single event.
  • wp simple-history event add to add an entry manually.
  • wp simple-history event search to search events.
  • wp simple-history db stats to get stats.
  • wp simple-history db clear to clear the events database.
  • wp simple-history event stick to stick an event to the top of the events list.
  • wp simple-history event unstick to unstick an event.
  • wp simple-history event is_sticky to check if an event is sticky.
  • wp simple-history event list_sticky [--format=<format>] to list events that are sticky.

See below for explanation of most of the commands.

WP-CLI event list command

List the latest events.

Filtering Options

The list command supports various filters to narrow down results:

Basic Parameters

ParameterDescription
--count=<number>Number of events to show (default: 10)
--format=<format>Output format: table, json, csv, yaml
--date_from=<date>Show events from this date (YYYY-MM-DD)
--date_to=<date>Show events until this date (YYYY-MM-DD)
--search=<text>Search for events containing this text

Inclusion Filters

ParameterDescription
--log_level=<levels>Include only events with these log levels (comma-separated)
--logger=<loggers>Include only events from these loggers (comma-separated)
--message=<messages>Include only specific message types in format “LoggerSlug:MessageKey” (comma-separated)
--user=<ids>Include only events by these user IDs (comma-separated)
--initiator=<types>Include only events by these initiators (comma-separated)

Exclusion Filters (Negative Filters)

Use these parameters to exclude events matching specific criteria:

ParameterDescription
--exclude_log_level=<levels>Exclude events with these log levels (comma-separated)
--exclude_logger=<loggers>Exclude events from these loggers (comma-separated)
--exclude_message=<messages>Exclude specific message types in format “LoggerSlug:MessageKey” (comma-separated)
--exclude_user=<ids>Exclude events by these user IDs (comma-separated)
--exclude_initiator=<types>Exclude events by these initiators (comma-separated)
--exclude_search=<text>Exclude events containing this text

Valid Initiator Values

  • wp_user – Regular WordPress user actions
  • wp_cli – Actions performed via WP-CLI
  • wp – WordPress system actions (cron jobs, automatic updates)
  • web_user – Non-logged-in web visitors
  • other – Other sources

Exclusion Filter Examples

# View events excluding debug level
wp simple-history list --exclude_log_level=debug --count=50

# Exclude WordPress system events (cron, auto-updates)
wp simple-history list --exclude_initiator=wp --count=50

# Exclude events containing "cron"
wp simple-history list --exclude_search=cron --count=50

# Exclude multiple log levels
wp simple-history list --exclude_log_level=debug,info --count=50

# Exclude specific message types
wp simple-history list --exclude_message=SimplePluginLogger:plugin_activated --count=50

# Combine filters: show user events, exclude admin user
wp simple-history list --initiator=wp_user --exclude_user=1 --count=50

# Show warning/error events only, exclude cron-related
wp simple-history list --log_level=warning,error --exclude_search=cron --count=50Code language: Bash (bash)

Note: When the same value appears in both an inclusion and exclusion filter, exclusion takes precedence.

WP-CLI event get command

Get information about a specific log entry.

WP-CLI event add command

Add a custom entry manually. This can be used to document important changes by creating custom log entries for team actions, content updates, or system changes that aren’t automatically tracked.

To add events using a GUI you can use the premium add-on.

WP-CLI search command

The search command searches the log for any word. In the example below we search for all events that contain the word “WooCommerce”:

WP-CLI db commands

The new “stats” and “clear” commands are used to interact with the database.

❯ wp simple-history db
usage: wp simple-history db clear
or: wp simple-history db stats [--format=]Code language: plaintext (plaintext)

The “stats” command gives you some short information about the sizes, in mb and in row count, of the databases that Simple History uses:

❯ wp simple-history db stats
+-----------------------------------+------------+----------+
| table_name                        | size_in_mb | num_rows |
+-----------------------------------+------------+----------+
| wp_stable_simple_history          | 0.34       | 1143     |
| wp_stable_simple_history_contexts | 6.20       | 12151    |
+-----------------------------------+------------+----------+

WP-CLI get command

The get command retrieves detailed information about a single event:

❯ wp simple-history get 1072
+-----------------------------+-------------------------------------------------------------+
| Field                       | Value                                                       |
+-----------------------------+-------------------------------------------------------------+
| ID                          | 1072                                                        |
| date                        | 2024-02-26 07:13:19                                         |
| initiator                   | WordPress                                                   |
| message                     | WordPress auto-updated to 6.4.3 from 6.4.2                  |
| via                         | null                                                        |
| logger                      | SimpleCoreUpdatesLogger                                     |
| level                       | notice                                                      |
| count                       | 1                                                           |
| _message_key                | core_auto_updated                                           |
| _message                    | WordPress auto-updated to {new_version} from {prev_version} |
| _initiator                  | wp                                                          |
| context_prev_version        | 6.4.2                                                       |
| context_new_version         | 6.4.3                                                       |
| context__message_key        | core_auto_updated                                           |
| context__wp_cron_running    | true                                                        |
| context__server_remote_addr | 127.0.0.1                                                   |
+-----------------------------+-------------------------------------------------------------+

Code language: plaintext (plaintext)

The clear command removes all items from the database:

❯ wp simple-history db clear
Are you sure you want to clear all logged items? [y/n] y
Success: Removed 1145 rows.Code language: plaintext (plaintext)