From 2b42d2ac29adedd1366a9b538d2908b04582d7c3 Mon Sep 17 00:00:00 2001 From: Ismo Vuorinen Date: Tue, 10 Dec 2013 14:17:31 +0200 Subject: [PATCH] =?UTF-8?q?Debug-ty=C3=B6kalu=20kehitysty=C3=B6n=20helpott?= =?UTF-8?q?amiseksi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/helpers/ecards_helper.php | 40 +++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/application/helpers/ecards_helper.php b/application/helpers/ecards_helper.php index ef378da..67f2676 100644 --- a/application/helpers/ecards_helper.php +++ b/application/helpers/ecards_helper.php @@ -435,3 +435,43 @@ function parseCardEntryValues($post) return $values; } + +/** + * debug + * handy little debugging commaind + * + * @param mixed $thing What you want to see + * @param boolean $show Should it be visible on page or only on source code + * + * @author Ismo Vuorinen + * @package Default + * + * @return true Script prints debugged thing, returns true always. + */ +function debug($thing = null, $show = false) +{ + if (ENVIRONMENT != "development") { + return false; + } + + // What triggered this? + $caller = array_shift(debug_backtrace()); + $from = str_replace(dirname(BASEPATH), '', $caller['file']) + . '#' . $caller['line']; + unset($caller); + + if ($show) { + $start = "\n
";
+        $end   = "\n
\n"; + } else { + $start = "\n\n"; + } + + $debug = $start . $from . "\n" . print_r($thing, true) . $end; + + echo $debug; + + return true; +} +