Logger Stores

Action Scheduler logging is handled by the ActionScheduler_Logger abstraction and two concrete implementations:

  • ActionScheduler_DBLogger (custom tables)
  • ActionScheduler_wpCommentLogger (legacy WP comments)

This document covers all public methods, filters, and persistence details for both loggers.

Logger Abstraction (ActionScheduler_Logger)

Located in classes/abstracts/ActionScheduler_Logger.php.

Instance Selection

ActionScheduler_Logger::instance() uses:

  • Default class: ActionScheduler_wpCommentLogger
  • Filter: action_scheduler_logger_class
$class = apply_filters( 'action_scheduler_logger_class', 'ActionScheduler_wpCommentLogger' );

Abstract Methods

  • log( $action_id, $message, ?DateTime $date = null )
  • get_entry( $entry_id )
  • get_logs( $action_id )

Public Methods (Shared Behavior)

init() attaches logging to core execution hooks:

  • action_scheduler_canceled_actionlog_canceled_action()
  • action_scheduler_begin_executelog_started_action()
  • action_scheduler_after_executelog_completed_action()
  • action_scheduler_failed_executionlog_failed_action()
  • action_scheduler_failed_actionlog_timed_out_action()
  • action_scheduler_unexpected_shutdownlog_unexpected_shutdown()
  • action_scheduler_reset_actionlog_reset_action()
  • action_scheduler_execution_ignoredlog_ignored_action()
  • action_scheduler_failed_fetch_actionlog_failed_fetch_action()
  • action_scheduler_failed_to_schedule_next_instancelog_failed_schedule_next_instance()
  • action_scheduler_bulk_cancel_actionsbulk_log_cancel_actions()

Other public methods:

  • hook_stored_action() / unhook_stored_action()
    • Attach/detach logging for action_scheduler_stored_action.
  • log_stored_action( $action_id )
  • log_canceled_action( $action_id )
  • log_started_action( $action_id, $context = '' )
  • log_completed_action( $action_id, $action = null, $context = '' )
  • log_failed_action( $action_id, Exception $exception, $context = '' )
  • log_timed_out_action( $action_id, $timeout )
  • log_unexpected_shutdown( $action_id, $error )
  • log_reset_action( $action_id )
  • log_ignored_action( $action_id, $context = '' )
  • log_failed_fetch_action( $action_id, ?Exception $exception = null )
  • log_failed_schedule_next_instance( $action_id, Exception $exception )
  • bulk_log_cancel_actions( $action_ids ) (default per-action fallback)

ActionScheduler_DBLogger (Custom Tables)

Located in classes/data-stores/ActionScheduler_DBLogger.php.

Storage Model

Logs are stored in the custom table actionscheduler_logs (registered via ActionScheduler_LoggerSchema).

Columns used:

  • log_id (primary key)
  • action_id
  • message
  • log_date_gmt
  • log_date_local

Public Methods

log( $action_id, $message, ?DateTime $date = null )

Inserts a log row into actionscheduler_logs with GMT and local timestamps.

get_entry( $entry_id )

Fetches a single log row and returns an ActionScheduler_LogEntry (or ActionScheduler_NullLogEntry if missing).

get_logs( $action_id )

Returns all log entries for an action.

init()

Initializes tables via ActionScheduler_LoggerSchema, calls parent init(), and hooks:

  • action_scheduler_deleted_actionclear_deleted_action_logs()

clear_deleted_action_logs( $action_id )

Deletes log rows for a deleted action.

bulk_log_cancel_actions( $action_ids )

Bulk inserts “action canceled” entries for a list of action IDs.

ActionScheduler_wpCommentLogger (WP Comments)

Located in classes/data-stores/ActionScheduler_wpCommentLogger.php.

Storage Model

Logs are stored as WordPress comments:

  • comment_post_ID = action ID
  • comment_type = action_log
  • comment_author / comment_agent = ActionScheduler
  • comment_content = message
  • comment_date / comment_date_gmt = log timestamp

Public Methods

log( $action_id, $message, ?DateTime $date = null )

Creates a comment via wp_insert_comment().

get_entry( $entry_id )

Returns a single ActionScheduler_LogEntry from a comment, or ActionScheduler_NullLogEntry for non-log comments.

get_logs( $action_id )

Loads all comment logs for an action via get_comments() and returns log entries in ascending date order.

filter_comment_queries( WP_Comment_Query $query )

Adds a filter to exclude Action Scheduler log comments from general comment queries.

filter_comment_query_clauses( $clauses, $query )

Adds a SQL WHERE clause to exclude comment_type = action_log.

filter_comment_feed( $where, WP_Query $query )

Excludes log comments from comment feeds.

filter_comment_count( $stats, $post_id )

Removes log comments from comment counts (and for global counts, removes order notes too).

delete_comment_count_cache()

Clears the cached comment counts when comments change.

init()

Hooks:

  • action_scheduler_before_process_queuedisable_comment_counting()
  • action_scheduler_after_process_queueenable_comment_counting()
  • pre_get_commentsfilter_comment_queries()
  • wp_count_commentsfilter_comment_count()
  • comment_feed_wherefilter_comment_feed()
  • wp_insert_comment / wp_set_comment_statusdelete_comment_count_cache()

disable_comment_counting() / enable_comment_counting()

Toggle comment count deferral to improve performance.

Filters and Actions

Filters

  • action_scheduler_logger_class — select logger implementation

Actions Consumed by Logger

  • action_scheduler_stored_action
  • action_scheduler_canceled_action
  • action_scheduler_begin_execute
  • action_scheduler_after_execute
  • action_scheduler_failed_execution
  • action_scheduler_failed_action
  • action_scheduler_unexpected_shutdown
  • action_scheduler_reset_action
  • action_scheduler_execution_ignored
  • action_scheduler_failed_fetch_action
  • action_scheduler_failed_to_schedule_next_instance
  • action_scheduler_bulk_cancel_actions