yoone-wc-moneris-payments/includes/utils/logger.php

31 lines
869 B
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
if (! defined('ABSPATH')) {
exit;
}
/**
* 统一日志工具(优先使用 WooCommerce Logger
*/
function yoone_moneris_log($level, $message, $context = array())
{
// $level: 'emergency'|'alert'|'critical'|'error'|'warning'|'notice'|'info'|'debug'
if (function_exists('wc_get_logger')) {
$logger = wc_get_logger();
$context = is_array($context) ? $context : array();
$context['source'] = 'yoone-moneris';
$logger->log($level, $message, $context);
return;
}
// 回退到 PHP error_log
error_log('[' . strtoupper((string) $level) . '] ' . $message);
}
function yoone_moneris_log_error($message, $context = array())
{
yoone_moneris_log('error', $message, $context);
}
function yoone_moneris_log_debug($message, $context = array())
{
yoone_moneris_log('debug', $message, $context);
}