wordpress-activitypub/includes/class-debug.php

31 lines
722 B
PHP
Raw Permalink Normal View History

2019-09-27 10:12:59 +02:00
<?php
namespace Activitypub;
/**
* ActivityPub Debug Class
*
* @author Matthias Pfefferle
*/
class Debug {
/**
* Initialize the class, registering WordPress hooks
*/
public static function init() {
if ( WP_DEBUG_LOG ) {
\add_action( 'activitypub_safe_remote_post_response', array( '\Activitypub\Debug', 'log_remote_post_responses' ), 10, 4 );
}
}
public static function log_remote_post_responses( $response, $url, $body, $user_id ) {
2019-09-28 14:17:58 +02:00
\error_log( "Request to: {$url} with response: " . \print_r( $response, true ) );
2019-09-27 10:12:59 +02:00
}
public static function write_log( $log ) {
if ( \is_array( $log ) || \is_object( $log ) ) {
2019-09-27 10:12:59 +02:00
\error_log( \print_r( $log, true ) );
} else {
\error_log( $log );
}
}
}