Skip to content

Commit e925504

Browse files
authored
Merge pull request #1039 from jonocodes/debug_env
feat(backend): introduce DEBUG_LOG env var
2 parents 84fc30f + fb4f45e commit e925504

File tree

9 files changed

+13
-8
lines changed

9 files changed

+13
-8
lines changed

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
APP_NAME=Cypht
22

3+
DEBUG_LOG=true
4+
35
DB_CONNECTION_TYPE=host
46
DB_DRIVER=mysql
57
DB_PORT=

config/app.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,8 @@
781781
// */
782782
// 'developer',
783783

784+
'debug_log' => env('DEBUG_LOG', false),
785+
784786
// /*
785787
// | -------
786788
// | Github

index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
new Hm_Dispatch($config);
5555

5656
/* log some debug stats about the page */
57-
if (DEBUG_MODE) {
57+
if (DEBUG_MODE or $config->get('debug_log')) {
5858
Hm_Debug::load_page_stats();
5959
Hm_Debug::show();
6060
}

lib/environment.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ public function define_default_constants($config) {
8787
define('DEFAULT_INLINE_MESSAGE_STYLE', $config->get('default_setting_inline_message_style', 'right'));
8888
define('DEFAULT_ENABLE_KEYBOARD_SHORTCUTS', $config->get('default_setting_enable_keyboard_shortcuts', false));
8989
define('DEFAULT_ENABLE_SIEVE_FILTER', $config->get('default_setting_enable_sieve_filter', false));
90+
define('DEFAULT_DEBUG_LOG', $config->get('debug_log', false));
9091
}
9192

9293
/**

lib/module.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ public function __construct($parent, $page, $output = [], $protected = []) {
347347
* @return string
348348
*/
349349
private function invalid_ajax_key() {
350-
if (DEBUG_MODE) {
350+
if (DEBUG_MODE or $this->config->get('debug_log')) {
351351
Hm_Debug::add('REQUEST KEY check failed');
352352
Hm_Debug::load_page_stats();
353353
Hm_Debug::show();

lib/modules_exec.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ public function __construct($config) {
234234
* @return void
235235
*/
236236
public function process_module_setup() {
237-
if (DEBUG_MODE) {
237+
if (DEBUG_MODE or $this->site_config->get('debug_log')) {
238238
$this->setup_debug_modules();
239239
}
240240
else {

modules/core/output_modules.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ protected function output() {
620620
'var hm_is_logged = function () { return '.($this->get('is_logged') ? '1' : '0').'; };'.
621621
'var hm_empty_folder = function() { return "'.$this->trans('So alone').'"; };'.
622622
'var hm_mobile = function() { return '.($this->get('is_mobile') ? '1' : '0').'; };'.
623-
'var hm_debug = function() { return "'.(DEBUG_MODE ? '1' : '0').'"; };'.
623+
'var hm_debug = function() { return "' . ((DEBUG_MODE || DEFAULT_DEBUG_LOG) ? '1' : '0') . '"; };'.
624624
'var hm_mailto = function() { return '.($this->get('mailto_handler') ? '1' : '0').'; };'.
625625
'var hm_page_name = function() { return "'.$this->html_safe($this->get('router_page_name')).'"; };'.
626626
'var hm_language_direction = function() { return "'.$this->html_safe($this->dir).'"; };'.
@@ -1313,7 +1313,7 @@ class Hm_Output_main_menu_start extends Hm_Output_Module {
13131313
*/
13141314
protected function output() {
13151315
$res = '';
1316-
if (DEBUG_MODE) {
1316+
if (DEBUG_MODE or DEFAULT_DEBUG_LOG) {
13171317
$res .= '<span title="'.
13181318
$this->trans('Running in debug mode. See https://cypht.org/install.html Section 6 for more detail.').
13191319
'" class="debug_title">'.$this->trans('Debug').'</span>';
@@ -1631,7 +1631,7 @@ class Hm_Output_content_section_start extends Hm_Output_Module {
16311631
* Opens a main tag for the primary content section
16321632
*/
16331633
protected function output() {
1634-
return '<main class="container-fluid content_cell" id="cypht-main"><div class="offline">'.$this->trans('Offline').'</div><div class="row m-0 position-relative">';
1634+
return '<main class="container-fluid content_cell" id="cypht-main"><div class="offline">'.$this->trans('Offline').'</div><div class="row m-0">';
16351635
}
16361636
}
16371637

modules/desktop_notifications/modules.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class Hm_Output_push_js_include extends Hm_Output_Module {
1111
protected function output() {
12-
if (DEBUG_MODE) {
12+
if (DEBUG_MODE or DEFAULT_DEBUG_LOG) {
1313
return '<script type="text/javascript" src="third_party/push.min.js"></script>';
1414
}
1515
}

tests/phpunit/modules/core/output_modules.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,7 @@ public function test_folder_list_end() {
981981
public function test_content_section_start() {
982982
$test = new Output_Test('content_section_start', 'core');
983983
$res = $test->run();
984-
$this->assertEquals(array('<main class="container-fluid content_cell" id="cypht-main"><div class="offline">Offline</div><div class="row m-0 position-relative">'), $res->output_response);
984+
$this->assertEquals(array('<main class="container-fluid content_cell" id="cypht-main"><div class="offline">Offline</div><div class="row m-0">'), $res->output_response);
985985
}
986986
/**
987987
* @preserveGlobalState disabled

0 commit comments

Comments
 (0)