<?php
|
namespace JVBase\managers;
|
|
use JVBase\Instance;
|
use WP_Error;
|
use Exception;
|
use WP_REST_Request;
|
|
if (!defined('ABSPATH')) {
|
exit; // Exit if accessed directly
|
}
|
|
class Errors
|
{
|
use Instance;
|
|
/**
|
* @param string $message
|
* @param array $context
|
* @return void
|
*/
|
public static function log(string $message, array $context = []):void
|
{
|
$msg = '{'.BASE.'}';
|
if (array_key_exists('class', $context)) {
|
$msg .= '['.$context['class'].']';
|
unset($context['class']);
|
}
|
if (array_key_exists('method', $context)) {
|
$msg .= '::'.$context['method'];
|
unset($context['method']);
|
}
|
if (array_key_exists('function', $context)) {
|
$msg .= $context['function'];
|
unset($context['function']);
|
}
|
error_log($msg.' '.$message);
|
if (!empty($context)) {
|
error_log('Context: '.print_r($context, true));
|
}
|
}
|
}
|