From 160a4e7326b0e71494c5c7c32a21d95e67c708a7 Mon Sep 17 00:00:00 2001 From: Eric van der Vlist Date: Fri, 15 May 2020 10:10:28 +0200 Subject: [PATCH] Log only when WP_DEBUG == true --- owark.php | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/owark.php b/owark.php index af181d9..792187d 100644 --- a/owark.php +++ b/owark.php @@ -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'] : '') . '/#' . (isset($caller_strace['line']) ? $caller_strace['line'] : '') . ' function: ' . (isset($caller_strace['function']) ? $caller_strace['function'] : '') . '('); - 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'] : '') . '/#' . (isset($caller_strace['line']) ? $caller_strace['line'] : '') . ' function: ' . (isset($caller_strace['function']) ? $caller_strace['function'] : '') . '('); + foreach ($caller_strace['args'] as $arg) { + error_log(' * ' . gettype($arg) . ': ' . print_r($arg, true)); + } } }