Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
8f140bee75 |
@ -17,7 +17,6 @@ namespace TheTempusProject\Canary\Bin;
|
|||||||
use TheTempusProject\Canary\Classes\TempusDebugger;
|
use TheTempusProject\Canary\Classes\TempusDebugger;
|
||||||
use TheTempusProject\Canary\Classes\Logger;
|
use TheTempusProject\Canary\Classes\Logger;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
class Canary {
|
class Canary {
|
||||||
|
|
||||||
private static $lastCall = '';
|
private static $lastCall = '';
|
||||||
@ -226,8 +225,8 @@ class Canary {
|
|||||||
if ( ! CANARY_ENABLED ) {
|
if ( ! CANARY_ENABLED ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( strlen( self::$debugLog ) > CANARY_DEBUG_LOG_LIMIT ) {
|
if ( strlen( self::$debugLog ) > 50000 ) {
|
||||||
self::$tempusLogger->addLog( 'log', 'Error log too large, possible loop.' );
|
self::$tempusDebugger->log( 'Error log too large, possible loop.' );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( is_object( $data ) ) {
|
if ( is_object( $data ) ) {
|
||||||
|
@ -18,7 +18,7 @@ if ( !defined( 'CANARY_ROOT_DIRECTORY' ) ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( ! defined('CANARY_CONFIG_DIRECTORY' ) ) {
|
if ( ! defined('CANARY_CONFIG_DIRECTORY' ) ) {
|
||||||
define('CANARY_CONFIG_DIRECTORY', CANARY_ROOT_DIRECTORY . 'Config' . DIRECTORY_SEPARATOR);
|
define('CANARY_CONFIG_DIRECTORY', CANARY_ROOT_DIRECTORY . 'config' . DIRECTORY_SEPARATOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! defined('CANARY_CONSTANTS_LOADED' ) ) {
|
if ( ! defined('CANARY_CONSTANTS_LOADED' ) ) {
|
||||||
@ -30,14 +30,12 @@ if ( class_exists( 'TheTempusProject\Hermes\Classes\Autoloader' ) ) {
|
|||||||
$autoloader->setRootFolder( CANARY_ROOT_DIRECTORY );
|
$autoloader->setRootFolder( CANARY_ROOT_DIRECTORY );
|
||||||
$autoloader->addNamespace(
|
$autoloader->addNamespace(
|
||||||
'TheTempusProject\Canary\Classes',
|
'TheTempusProject\Canary\Classes',
|
||||||
'Classes'
|
'classes'
|
||||||
);
|
);
|
||||||
$autoloader->addNamespace(
|
$autoloader->addNamespace(
|
||||||
'TheTempusProject\Canary',
|
'TheTempusProject\Canary',
|
||||||
'Bin'
|
'bin'
|
||||||
);
|
);
|
||||||
$Autoloader->register();
|
$Autoloader->register();
|
||||||
define( 'CANARY_AUTOLOADED', true );
|
define( 'CANARY_AUTOLOADED', true );
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once 'Canary.php';
|
|
@ -1,78 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Classes/CustomException.php
|
|
||||||
*
|
|
||||||
* This class is used exclusively when throwing predefined exceptions.
|
|
||||||
* It will intercept framework thrown exceptions and deal with them however
|
|
||||||
* you choose; in most cases by logging them and taking appropriate responses
|
|
||||||
* such as redirecting to error pages.
|
|
||||||
*
|
|
||||||
* @version 3.0
|
|
||||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
|
||||||
* @link https://TheTempusProject.com/Canary
|
|
||||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
|
||||||
*/
|
|
||||||
namespace TheTempusProject\Canary\Classes;
|
|
||||||
|
|
||||||
use Exception;
|
|
||||||
use TheTempusProject\Hermes\Functions\Redirect;
|
|
||||||
use TheTempusProject\Canary\Bin\Canary as Debug;
|
|
||||||
|
|
||||||
class CustomException extends Exception {
|
|
||||||
private $originFunction = null;
|
|
||||||
private $exceptionName = null;
|
|
||||||
private $originClass = null;
|
|
||||||
private $data = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This function allows the application to deal with errors
|
|
||||||
* in a dynamic way by letting you customize the response
|
|
||||||
*
|
|
||||||
* @param string $type - The type of the exception being called/thrown.
|
|
||||||
* @param string $data - Any additional data being passed with the exception.
|
|
||||||
*
|
|
||||||
* @example - throw new CustomException('model'); - Calls the model-missing exception
|
|
||||||
*/
|
|
||||||
public function __construct( $type, $data = null ) {
|
|
||||||
$this->originFunction = debug_backtrace()[1]['function'];
|
|
||||||
$this->originClass = debug_backtrace()[1]['class'];
|
|
||||||
$this->exceptionName = $type;
|
|
||||||
$this->data = $data;
|
|
||||||
switch ( $type ) {
|
|
||||||
case 'model':
|
|
||||||
Debug::error( 'Model not found: ' . $data );
|
|
||||||
break;
|
|
||||||
case 'dbConnection':
|
|
||||||
Debug::error( 'Error Connecting to the database: ' . $data );
|
|
||||||
break;
|
|
||||||
case 'DB':
|
|
||||||
Debug::error( 'Unspecified database error: ' . $data );
|
|
||||||
break;
|
|
||||||
case 'view':
|
|
||||||
Debug::error( 'View not found: ' . $data );
|
|
||||||
break;
|
|
||||||
case 'controller':
|
|
||||||
Debug::error( 'Controller not found: ' . $data );
|
|
||||||
Redirect::to( 404 );
|
|
||||||
break;
|
|
||||||
case 'defaultController':
|
|
||||||
Debug::error( 'DEFAULT Controller not found: ' . $data );
|
|
||||||
Redirect::to( 404 );
|
|
||||||
break;
|
|
||||||
case 'method':
|
|
||||||
Debug::error( 'Method not found: ' . $data );
|
|
||||||
Redirect::to( 404 );
|
|
||||||
break;
|
|
||||||
case 'simpleView':
|
|
||||||
Debug::error( 'View not found: ' . $data );
|
|
||||||
break;
|
|
||||||
case 'defaultMethod':
|
|
||||||
Debug::error( 'DEFAULT Method not found: ' . $data );
|
|
||||||
Redirect::to( 404 );
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
Debug::error( 'Default exception: ' . $data );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -17,7 +17,6 @@ class Logger {
|
|||||||
$this->file = fopen( $this->logFilePath, 'a' );
|
$this->file = fopen( $this->logFilePath, 'a' );
|
||||||
fwrite( $this->file, '===================------++++++++++------===================' . PHP_EOL );
|
fwrite( $this->file, '===================------++++++++++------===================' . PHP_EOL );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setupLogFile() {
|
public function setupLogFile() {
|
||||||
$this->logDirectory = rtrim( CANARY_DEBUG_DIRECTORY, DIRECTORY_SEPARATOR );
|
$this->logDirectory = rtrim( CANARY_DEBUG_DIRECTORY, DIRECTORY_SEPARATOR );
|
||||||
if ( ! is_dir( $this->logDirectory ) ) {
|
if ( ! is_dir( $this->logDirectory ) ) {
|
||||||
@ -32,13 +31,12 @@ class Logger {
|
|||||||
chmod( $this->logFilePath, 0777 );
|
chmod( $this->logFilePath, 0777 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __destruct() {
|
public function __destruct() {
|
||||||
fwrite( $this->file, '============================================================' . PHP_EOL );
|
fwrite( $this->file, '============================================================' . PHP_EOL );
|
||||||
fclose( $this->file );
|
fclose( $this->file );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addLog( $type = 'log', $log = '' ) {
|
public function addLog( $type = 'log', $log ) {
|
||||||
switch ( CANARY_DEBUG_TO_FILE_LEVEL ) {
|
switch ( CANARY_DEBUG_TO_FILE_LEVEL ) {
|
||||||
case CANARY_DEBUG_LEVEL_ERROR:
|
case CANARY_DEBUG_LEVEL_ERROR:
|
||||||
$acceptableLoggingLevels = [
|
$acceptableLoggingLevels = [
|
||||||
|
@ -48,9 +48,6 @@ if ( ! defined( 'CANARY_SHOW_LINES' ) ) {
|
|||||||
if ( ! defined('CANARY_DEBUG_TO_CONSOLE' ) ) {
|
if ( ! defined('CANARY_DEBUG_TO_CONSOLE' ) ) {
|
||||||
define( 'CANARY_DEBUG_TO_CONSOLE', false );
|
define( 'CANARY_DEBUG_TO_CONSOLE', false );
|
||||||
}
|
}
|
||||||
if ( ! defined('CANARY_DEBUG_LOG_LIMIT' ) ) {
|
|
||||||
define( 'CANARY_DEBUG_LOG_LIMIT', 500000 );
|
|
||||||
}
|
|
||||||
|
|
||||||
# Tell the app all constants have been loaded.
|
# Tell the app all constants have been loaded.
|
||||||
if ( ! defined('CANARY_CONSTANTS_LOADED' ) ) {
|
if ( ! defined('CANARY_CONSTANTS_LOADED' ) ) {
|
||||||
|
20
composer.lock
generated
20
composer.lock
generated
@ -1,20 +0,0 @@
|
|||||||
{
|
|
||||||
"_readme": [
|
|
||||||
"This file locks the dependencies of your project to a known state",
|
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
|
||||||
"This file is @generated automatically"
|
|
||||||
],
|
|
||||||
"content-hash": "2766960a50e2f2f76a8ec41e644bc0de",
|
|
||||||
"packages": [],
|
|
||||||
"packages-dev": [],
|
|
||||||
"aliases": [],
|
|
||||||
"minimum-stability": "dev",
|
|
||||||
"stability-flags": [],
|
|
||||||
"prefer-stable": false,
|
|
||||||
"prefer-lowest": false,
|
|
||||||
"platform": {
|
|
||||||
"php": ">=8.1.0"
|
|
||||||
},
|
|
||||||
"platform-dev": [],
|
|
||||||
"plugin-api-version": "2.3.0"
|
|
||||||
}
|
|
2
logs/.gitignore
vendored
2
logs/.gitignore
vendored
@ -1,2 +0,0 @@
|
|||||||
*
|
|
||||||
!.gitignore
|
|
Reference in New Issue
Block a user