1. Go to this page and download the library: Download underpin/logger-loader 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/ */
$item_1 = function_that_returns_errors();
$item_2 = another_function_that_returns_errors();
$errors = underpin()->logger()->gather_errors($item_1,$item_2);
if($errors->has_errors()){
// Do do something if either of the items were a WP Error.
} else{
// All clear, proceed.
}
namespace Plugin_Name_Replace_Me\Event_Types;
/**
* Class Background_Process
* Error event type.
*
* @since 1.0.0
*
* @since
* @package
*/
class Background_Process extends Event_Type {
/**
* Event type
*
* @since 1.0.0
*
* @var string
*/
public $type = 'background_process';
/**
* Writes this to the log.
* Set this to true to cause this event to get written to the log.
*
* @since 1.0.0
*
* @var bool
*/
protected $write_to_log = true;
/**
* @var inheritDoc
*/
public $description = 'Logs when background processes run.';
/**
* @var inheritDoc
*/
public $name = "Background Processes";
}
/**
* Set up active loader classes.
*
* This is where you can add anything that needs "registered" to WordPress,
* such as shortcodes, rest endpoints, blocks, and cron jobs.
*
* All supported loaders come pre-packaged with this plugin, they just need un-commented here
* to begin using.
*
* @since 1.0.0
*/
protected function _setup() {
plugin_name_replace_me()->logger()->add('background_process', '\Plugin_Name_Replace_Me\Event_Types\Background_Process');
}
namespace Plugin_Name_Replace_Me\Event_Types;
/**
* Class Background_Process
* Error event type.
*
* @since 1.0.0
*
* @since
* @package
*/
class Background_Process extends Event_Type {
/**
* Event type
*
* @since 1.0.0
*
* @var string
*/
public $type = 'background_process';
/**
* Writes this to the log.
* Set this to true to cause this event to get written to the log.
*
* @since 1.0.0
*
* @var bool
*/
protected $write_to_log = true;
/**
* @var inheritDoc
*/
public $description = 'Logs when background processes run.';
/**
* @var inheritDoc
*/
public $name = "Background Processes";
/**
* The class to instantiate when writing to the error log.
*
* @since 1.0.0
*
* @var string Namespaced instance of writer class.
*/
public $writer_class = 'Plugin_Name_Replace_Me\Factories\Email_Logger';
}