Log only when WP_DEBUG == true

这个提交包含在:
Eric van der Vlist 2020-05-15 10:10:28 +02:00
父节点 5ee8aba026
当前提交 160a4e7326
共有 1 个文件被更改,包括 15 次插入11 次删除

查看文件

@ -20,7 +20,7 @@
Plugin Name: owark
Plugin URI: http://owark.org
Description: Tired of broken links? Archive yours with owark, the Open Web Archive!
Version: 1.0
Version: 1.0.1
Author: Eric van der Vlist
Author URI: http://eric.van-der-vlist.com
License: GLP2
@ -33,12 +33,14 @@
if (!function_exists('print_r_log')) {
function print_r_log($log) {
$caller_strace = debug_backtrace()[1];
if (is_array($log) || is_object($log)) {
error_log($caller_strace['file'] . '/#' . $caller_strace['line'] . ':');
error_log(print_r($log, true));
} else {
error_log($caller_strace['file'] . '/#' . $caller_strace['line'] . ': ' . $log);
if (defined('WP_DEBUG') && WP_DEBUG == true) {
$caller_strace = debug_backtrace()[1];
if (is_array($log) || is_object($log)) {
error_log($caller_strace['file'] . '/#' . $caller_strace['line'] . ':');
error_log(print_r($log, true));
} else {
error_log($caller_strace['file'] . '/#' . $caller_strace['line'] . ': ' . $log);
}
}
}
@ -47,10 +49,12 @@ if (!function_exists('print_r_log')) {
if (!function_exists('log_function_call')) {
function log_function_call() {
$caller_strace = debug_backtrace()[1];
error_log((isset($caller_strace['file']) ? $caller_strace['file'] : '<undefined>') . '/#' . (isset($caller_strace['line']) ? $caller_strace['line'] : '<undefined>') . ' function: ' . (isset($caller_strace['function']) ? $caller_strace['function'] : '<undefined>') . '(');
foreach ($caller_strace['args'] as $arg) {
error_log(' * ' . gettype($arg) . ': ' . print_r($arg, true));
if (defined('WP_DEBUG') && WP_DEBUG == true) {
$caller_strace = debug_backtrace()[1];
error_log((isset($caller_strace['file']) ? $caller_strace['file'] : '<undefined>') . '/#' . (isset($caller_strace['line']) ? $caller_strace['line'] : '<undefined>') . ' function: ' . (isset($caller_strace['function']) ? $caller_strace['function'] : '<undefined>') . '(');
foreach ($caller_strace['args'] as $arg) {
error_log(' * ' . gettype($arg) . ': ' . print_r($arg, true));
}
}
}