Skip to content

Instantly share code, notes, and snippets.

@scossar
Created August 23, 2023 09:49
Show Gist options
  • Save scossar/231264166bd1e6633fea08d907867651 to your computer and use it in GitHub Desktop.
Save scossar/231264166bd1e6633fea08d907867651 to your computer and use it in GitHub Desktop.
A tiny WordPress plugin that writes a comma separated list of arguments to a debug.log file
<?php
/**
* Plugin Name: log error
* Version: 0.1
* Author: scossar
*/
function write_log( ...$log_items ) {
if ( true === WP_DEBUG ) {
foreach ( $log_items as $log_item ) {
if ( is_array( $log_item ) || is_object( $log_item ) ) {
error_log( print_r( $log_item, true ) );
} else {
error_log( $log_item );
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment