PHP code example of arraypress / wp-logger

1. Go to this page and download the library: Download arraypress/wp-logger library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

arraypress / wp-logger example snippets


// Once, during bootstrap.
register_logger( 'sugarcart' );

// Anywhere after that.
$log = get_logger( 'sugarcart' );

$log->info( 'Order completed', [ 'order_id' => 1001, 'total' => 4999 ] );

try {
    $gateway->charge( $order );
} catch ( GatewayException $e ) {
    $log->exception( $e, [ 'order_id' => $order->id ] );
}

// WP_Error keeps its code and data.
$response = wp_remote_post( $url, $args );

if ( is_wp_error( $response ) ) {
    $log->wp_error( $response );
}