PHP code example of thedigitalembassy / adeptus

1. Go to this page and download the library: Download thedigitalembassy/adeptus 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/ */

    

thedigitalembassy / adeptus example snippets


\Adeptus::disableLogging();

// your code here...

\Adeptus::enableLogging();

function do_import() 
{
    \Adeptus::logEvent([
        'alert_code'        => 20080,
        'alert_level'       => \Psr\Log\LogLevel::INFO,
        'alert_title'       => 'Import Started',
        'alert_description' => 'Import Started',
        'sensor'            => 'ImportExample'
    ]);

    \Adeptus::disableLogging();

    // Perform import
    update_option('blogname',rand());

    \Adeptus::enableLogging();

    \Adeptus::logEvent([
        'alert_code'        => 20080,
        'alert_level'       => \Psr\Log\LogLevel::INFO,
        'alert_title'       => 'Import Finished',
        'alert_description' => 'Imported 100 items successfully',
        'sensor'            => 'ImportExample'
    ]);
}

class MyLogger implements \Psr\Log\LoggerInterface {
    //...
}

add_action('adeptus/loggers', function($alert_manager) {
    $logger = new MyLogger();
    $alert_manager->setLogger($logger);
});