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