/var/www/vhosts/ihelp.ro/ajutam.ro/wp-content/plugins/give/src/Log
Edit: /var/www/vhosts/ihelp.ro/ajutam.ro/wp-content/plugins/give/src/Log/Log.php (3672B)
'Payment',
* 'source' => 'Stripe add-on'
* ] );
*
* @note Use as many contexts attributes as you need. The more the better.
*
* @example
*
* Log::error( 'Error message', [
* 'category' => 'Payment',
* 'source' => 'Stripe add-on',
* 'donation_id' => $donationId,
* 'donor_id' => $donorId
* ] );
*
* @note You can use an array or object as a context attribute value.
*
* @example
*
* try {
* something();
* } catch ( Exception $exception ) {
* Log::error( 'Something went wrong', [
* 'exception' => $exception,
* 'additional_info' => [
* 'donation_id' => $donationId
* ]
* ] );
* }
*
*
* @method static error(string $message, array $context = [])
* @method static warning(string $message, array $context = [])
* @method static notice(string $message, array $context = [])
* @method static success(string $message, array $context = [])
* @method static info(string $message, array $context = [])
* @method static http(string $message, array $context = [])
* @method static spam(string $message, array $context = [])
*/
class Log
{
public function __call($name, $arguments)
{
list ($message, $context) = array_pad($arguments, 2, null);
if (is_array($context)) {
// Convert context values to string
$context = array_map(
function ($item) {
if (is_array($item) || is_object($item)) {
$item = print_r($item, true);
}
return $item;
},
$context
);
// Default fields
$data = array_filter(
$context,
function ($key) {
return array_key_exists($key, LogFactory::getDefaults());
},
ARRAY_FILTER_USE_KEY
);
// Additional context
$data['context'] = array_diff(
$context,
$data
);
}
// Set message
if (!is_null($message)) {
$data['message'] = $message;
}
// Set type
$data['type'] = $name;
try {
$log = LogFactory::makeFromArray($data);
$log->save();
return $log;
} catch (Exception $exception) {
error_log($exception->getMessage());
}
}
/**
* Static helper for calling the logger methods
*
* @param string $name
* @param array $arguments
*
* @since 2.18.0 - always log errors, warnings & only log all if WP_DEBUG_LOG is enabled
* @since 2.11.1
*
*/
public static function __callStatic($name, $arguments)
{
/** @var Log $logger */
$logger = give(__CLASS__);
if (in_array($name, ['error', 'warning']) || Environment::isDebugLoggingEnabled()) {
call_user_func_array([$logger, $name], $arguments);
}
}
}