隐藏正式环境日志

deploy
DESKTOP-4RNDQIC\29019 2021-02-23 20:46:33 +08:00
parent 0ac0580fab
commit 1ae683ab85
3 changed files with 34 additions and 4 deletions

View File

@ -10,6 +10,22 @@ namespace Core;
class Error
{
/**
* Error handler. Convert all errors to Exceptions by throwing an ErrorException.
*
* @param int $level Error level
* @param string $message Error message
* @param string $file Filename the error was raised in
* @param int $line Line number in the file
*
* @return void
*/
public static function errorHandlerNone($level, $message, $file, $line)
{
echo "Handler captured error $level: '$message'" . PHP_EOL;
}
/**
* Error handler. Convert all errors to Exceptions by throwing an ErrorException.
*
@ -63,4 +79,7 @@ class Error
View::renderTemplate("$code.html");
}
}
public static function exceptionHandlerNone($exception){
}
}

View File

@ -50,7 +50,8 @@ abstract class Model
PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => false,
);
static $db = null;
$option=array();
$timeout=time() + 20;
if ($db === null) {
$dsn = 'mysql:host=' . Config::DB_HOST . ';dbname=' . Config::DB_NAME . ';charset=utf8';
try {

View File

@ -7,14 +7,24 @@
/**
* Composer
*/
require dirname(__DIR__) . '/vendor/autoload.php';
require dirname(__DIR__) . '/App/Config.php';
/**
* Error and Exception handling
*/
error_reporting(E_ALL);
set_error_handler('Core\Error::errorHandler');
set_exception_handler('Core\Error::exceptionHandler');
if($_SERVER['HTTP_HOST'] == '127.0.0.1'){
error_reporting(E_ALL);
set_error_handler('Core\Error::errorHandler');
set_exception_handler('Core\Error::exceptionHandler');
}else{
error_reporting(0);
set_error_handler('Core\Error::errorHandlerNone');
set_exception_handler('Core\Error::exceptionHandlerNone');
}
/**
* Routing
*/