Better logging
This commit is contained in:
parent
664db2fb7c
commit
fe40f99ebd
16
index.php
16
index.php
@ -1,6 +1,16 @@
|
||||
<?php
|
||||
ini_set("display_errors", "off");
|
||||
|
||||
// Logging must be defined early on:
|
||||
class Framework
|
||||
{
|
||||
public static function log()
|
||||
{
|
||||
$strText = implode(" ", func_get_args());
|
||||
error_log("INFO: {$strText}");
|
||||
}
|
||||
}
|
||||
|
||||
// For compatibility with PHP 5.3.0:
|
||||
$varConstants = array(
|
||||
array("JSON_HEX_TAG", 1),
|
||||
@ -80,6 +90,7 @@
|
||||
|
||||
if ($intValid)
|
||||
{
|
||||
Framework::log("Sending file {$strTargetFilePath}");
|
||||
ob_clean();
|
||||
echo file_get_contents($strTargetFilePath);
|
||||
ob_end_flush();
|
||||
@ -114,7 +125,10 @@
|
||||
$strLibraryFilePath = "{$strLibraryDirPath}/{$strLibraryFileName}";
|
||||
if (preg_match("/\.php$/", $strLibraryFilePath))
|
||||
if (is_file($strLibraryFilePath))
|
||||
{
|
||||
Framework::log("Requiring library {$strLibraryFilePath}");
|
||||
require $strLibraryFilePath;
|
||||
}
|
||||
}
|
||||
|
||||
$strBodyTagAttributes = "";
|
||||
@ -126,7 +140,7 @@
|
||||
{
|
||||
if (is_file($strScript))
|
||||
{
|
||||
error_log($strScript);
|
||||
Framework::log("Requiring {$strScript}");
|
||||
require $strScript;
|
||||
}
|
||||
}
|
||||
|
@ -15,8 +15,6 @@
|
||||
if ($strParam == null)
|
||||
$strParam = "";
|
||||
|
||||
error_log("INFO: " . json_encode($_SERVER, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
|
||||
|
||||
foreach (["REQUEST_URI", "PATH_INFO"] as $k)
|
||||
if (strlen($strParam) < 1)
|
||||
{
|
||||
@ -36,8 +34,6 @@
|
||||
if (strlen($_SERVER["PATH_INFO"]) > 0)
|
||||
$strParam = $_SERVER["PATH_INFO"];
|
||||
}
|
||||
|
||||
//error_log(json_encode($_SERVER, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
|
||||
|
||||
$strPath = $strParam;
|
||||
$strPath = preg_replace("/^\//", "", $strPath);
|
||||
@ -92,8 +88,6 @@
|
||||
|
||||
array_shift($varArgs);
|
||||
|
||||
error_log($strParam);
|
||||
|
||||
Request::$varArgs = $varArgs;
|
||||
Request::$strResourcePath = $strPath;
|
||||
}
|
||||
@ -217,18 +211,9 @@
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function log()
|
||||
{
|
||||
//$strPath = $_SERVER["PATH_INFO"];
|
||||
|
||||
error_log("[{$strPath}] INFO: " . implode(" ", func_get_args()));
|
||||
}
|
||||
}
|
||||
|
||||
// Call this no matter what to understand the request:
|
||||
Request::process();
|
||||
Request::processExtra();
|
||||
|
||||
Request::log("");
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user