Log only when WP_DEBUG == true
This commit is contained in:
parent
5ee8aba026
commit
160a4e7326
26
owark.php
26
owark.php
|
@ -20,7 +20,7 @@
|
||||||
Plugin Name: owark
|
Plugin Name: owark
|
||||||
Plugin URI: http://owark.org
|
Plugin URI: http://owark.org
|
||||||
Description: Tired of broken links? Archive yours with owark, the Open Web Archive!
|
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: Eric van der Vlist
|
||||||
Author URI: http://eric.van-der-vlist.com
|
Author URI: http://eric.van-der-vlist.com
|
||||||
License: GLP2
|
License: GLP2
|
||||||
|
@ -33,12 +33,14 @@
|
||||||
if (!function_exists('print_r_log')) {
|
if (!function_exists('print_r_log')) {
|
||||||
|
|
||||||
function print_r_log($log) {
|
function print_r_log($log) {
|
||||||
$caller_strace = debug_backtrace()[1];
|
if (defined('WP_DEBUG') && WP_DEBUG == true) {
|
||||||
if (is_array($log) || is_object($log)) {
|
$caller_strace = debug_backtrace()[1];
|
||||||
error_log($caller_strace['file'] . '/#' . $caller_strace['line'] . ':');
|
if (is_array($log) || is_object($log)) {
|
||||||
error_log(print_r($log, true));
|
error_log($caller_strace['file'] . '/#' . $caller_strace['line'] . ':');
|
||||||
} else {
|
error_log(print_r($log, true));
|
||||||
error_log($caller_strace['file'] . '/#' . $caller_strace['line'] . ': ' . $log);
|
} 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')) {
|
if (!function_exists('log_function_call')) {
|
||||||
|
|
||||||
function log_function_call() {
|
function log_function_call() {
|
||||||
$caller_strace = debug_backtrace()[1];
|
if (defined('WP_DEBUG') && WP_DEBUG == true) {
|
||||||
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>') . '(');
|
$caller_strace = debug_backtrace()[1];
|
||||||
foreach ($caller_strace['args'] as $arg) {
|
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>') . '(');
|
||||||
error_log(' * ' . gettype($arg) . ': ' . print_r($arg, true));
|
foreach ($caller_strace['args'] as $arg) {
|
||||||
|
error_log(' * ' . gettype($arg) . ': ' . print_r($arg, true));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue