Skip to content

Log Handlers

Sean Fisher edited this page Sep 1, 2022 · 5 revisions

Query Monitor

A Query Monitor handler allows piping to the query monitor on the page, providing helpful debug information about the current WordPress request.

Log Post Type Handler

Send a log to a WordPress Log Post Type to be viewed globally across the WordPress installation.

Throttling

In order to prevent multiple log entries from being written to the database (especially on high volume sites), each unique log entry is limited to one per 15 minutes. A log entry is considered unique if it has the same $key (Title) and $args['context'].

The exception to this rule is if WP_DEBUG is set to true, in which case, every log entry will be recorded and throttling is disabled.

Info Log Entries

Log entries with a level of info will only be written to the database if WP_DEBUG is true

Post / Term Handlers

The plugin includes Monolog Handlers for logging directly to a Post's or Term's meta. By logging to a object's meta, you can drill down into specific events that relate to the object very quickly. Both handlers require the additional $object_id and optional $log_key parameters on the handler's constructor.

CLI Handler

Pipe the log record directly to the WP-CLI output.

Exception Handler

Forward the log to a catchable exception AI_Logger\Handler\Handler_Exception. Only emergency, alert, and critical events will thrown an exception.

Examples

Logging to a Specific Post

Logs will be appended to a post's meta for review.

ai_logger_to_post( $post_id, 'meta-key' )->info( 'This will log to the <meta-key> for a specific post.' );

Logging to a Specific Term

Logs will be appended to a term's meta for review.

ai_logger_to_term( $term_id, 'meta-key' )->info( 'This will log to the <meta-key> for a specific term.' );

Logging to Query Monitor

ai_logger_to_qm()->info( 'This will show up in Query Monitor!' );