From f644890e3abdd1b0ea2009750ea451907d1c914b Mon Sep 17 00:00:00 2001 From: Sheldon Lee Date: Sun, 12 Nov 2023 22:45:19 +0800 Subject: [PATCH] Add logging functions --- php/logging.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 php/logging.php diff --git a/php/logging.php b/php/logging.php new file mode 100644 index 0000000..0edd625 --- /dev/null +++ b/php/logging.php @@ -0,0 +1,29 @@ +"; + return; + } + + $handle = fopen(LOG_FILE, "a"); + if (!$handle) { + echo "Unable to open file.
"; + return; + } + + if (!fwrite($handle, $string . "\n")) { + echo "Unable to write to file.
"; + } + fclose($handle); +} + +function log_error($string) +{ + log_print(PREFIX_ERROR . $string); +} +?>