aboutsummaryrefslogtreecommitdiff
path: root/lib/Debug.php
diff options
context:
space:
mode:
authorGravatar logmanoriginal <logmanoriginal@users.noreply.github.com> 2018-11-10 20:03:03 +0100
committerGravatar logmanoriginal <logmanoriginal@users.noreply.github.com> 2018-11-10 20:03:05 +0100
commitc63af2e7ad34c7a900259eddc0c65877ba3cfeb5 (patch)
tree247ad9fd1636a3bf3665902097e9995a95beb2da /lib/Debug.php
parent9379854f7a41a52b34b12fb7cd086a4cda15dbbe (diff)
downloadrss-bridge-c63af2e7ad34c7a900259eddc0c65877ba3cfeb5.tar.gz
rss-bridge-c63af2e7ad34c7a900259eddc0c65877ba3cfeb5.tar.zst
rss-bridge-c63af2e7ad34c7a900259eddc0c65877ba3cfeb5.zip
core: Add separate Debug class
Replaces 'debugMessage' by specialized debug function 'Debug::log'. This function takes the same arguments as the previous 'debugMessage'. A separate Debug class allows for further optimization and separation of concern.
Diffstat (limited to 'lib/Debug.php')
-rw-r--r--lib/Debug.php19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/Debug.php b/lib/Debug.php
new file mode 100644
index 00000000..7d1f498d
--- /dev/null
+++ b/lib/Debug.php
@@ -0,0 +1,19 @@
+<?php
+
+class Debug {
+ public static function log($text) {
+ if(!DEBUG) {
+ return;
+ }
+
+ $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3);
+ $calling = $backtrace[2];
+ $message = $calling['file'] . ':'
+ . $calling['line'] . ' class '
+ . (isset($calling['class']) ? $calling['class'] : '<no-class>') . '->'
+ . $calling['function'] . ' - '
+ . $text;
+
+ error_log($message);
+ }
+}