Create config options for stacktraces

This commit is contained in:
Belle Aerni committed 2022-10-29 00:48:01 -07:00
1 parent 644768fb86
commit 47e30ff536
4 files changed
+19 -3

No files matched your search

+9
View File
@@ -29,6 +29,15 @@ return [
*/
'debug' => false,
/**
* Enable or disable stacktraces when an exception is thrown (also requires debug to be enabled).
*/
'log_stacktrace' => true,
/**
* How long the stacktrace should be.
*/
'stacktrace_length' => 25,
'maintenance_mode' => [
/**
* Enable or disable the system maintenance mode.
+6 -3
View File
@@ -23,10 +23,13 @@ class Box_Exception extends Exception
public function __construct($message, array $variables = NULL, $code = 0)
{
$config = include BB_PATH_ROOT.'/bb-config.php';
$debug = (isset($config['debug'])) ? isset($config['debug']) : false;
$logStack = (isset($config['log_stacktrace'])) ? isset($config['log_stacktrace']) : true;
$stackLength = (isset($config['stacktrace_length'])) ? isset($config['stacktrace_length']) : 25;
if(isset($config['debug']) && $config['debug'] === true){
error_log('An exception has been called. Stacktrace:');
error_log( $this->stackTrace() );
if($debug && $logStack){
error_log('An exception has been thrown. Stacktrace:');
error_log( $this->stackTrace($stackLength) );
}
// Set the message
+2
View File
@@ -490,6 +490,8 @@ class Box_Tools
$newConfig = [
'debug' => (isset($currentConfig['debug'])) ? $currentConfig['debug'] : false,
'log_stacktrace' => (isset($currentConfig['log_stacktrace'])) ? $currentConfig['log_stacktrace'] : true,
'stacktrace_length' => (isset($currentConfig['stacktrace_length'])) ? $currentConfig['stacktrace_length'] : 25,
'maintenance_mode' => [
'enabled' => (isset($currentConfig['maintenance_mode']['enabled'])) ? $currentConfig['maintenance_mode']['enabled'] : false,
'allowed_urls' => (isset($currentConfig['maintenance_mode']['allowed_urls'])) ? $currentConfig['maintenance_mode']['allowed_urls'] : [],
+2
View File
@@ -411,6 +411,8 @@ final class Box_Installer
// TODO: Why not just take the defaults from the bb.config.example.php file and modify accordingly? Also this method doesn't preserve the comments in the example config.
$data = [
'debug' => false,
'log_stacktrace' => true,
'stacktrace_length' => 25,
'maintenance_mode' => [
'enabled' => false,