Add logging functions
This commit is contained in:
parent
39928a2c56
commit
f644890e3a
29
php/logging.php
Normal file
29
php/logging.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
//define("DEBUG", null);
|
||||
define("LOG_FILE", __DIR__ . "/../php.log");
|
||||
define("PREFIX_ERROR", "Error: ");
|
||||
|
||||
function log_print($string)
|
||||
{
|
||||
if(defined("DEBUG") && !defined("NO_ECHO")) {
|
||||
echo $string . "<br>";
|
||||
return;
|
||||
}
|
||||
|
||||
$handle = fopen(LOG_FILE, "a");
|
||||
if (!$handle) {
|
||||
echo "Unable to open file.<br>";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!fwrite($handle, $string . "\n")) {
|
||||
echo "Unable to write to file.<br>";
|
||||
}
|
||||
fclose($handle);
|
||||
}
|
||||
|
||||
function log_error($string)
|
||||
{
|
||||
log_print(PREFIX_ERROR . $string);
|
||||
}
|
||||
?>
|
Loading…
Reference in New Issue
Block a user