Skip to content

Commit 3bbcedd

Browse files
committed
Set severity to hm debug messages
1 parent 8b2ade5 commit 3bbcedd

File tree

23 files changed

+63
-56
lines changed

23 files changed

+63
-56
lines changed

lib/cache.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,11 @@ private function prep_out($data, $crypt_key) {
201201
*/
202202
private function configured() {
203203
if (!$this->server || !$this->port) {
204-
Hm_Debug::add(sprintf('%s enabled but no server or port found', $this->type));
204+
Hm_Debug::add(sprintf('%s enabled but no server or port found', $this->type), 'warning');
205205
return false;
206206
}
207207
if (!$this->supported) {
208-
Hm_Debug::add(sprintf('%s enabled but not supported by PHP', $this->type));
208+
Hm_Debug::add(sprintf('%s enabled but not supported by PHP', $this->type), 'warning');
209209
return false;
210210
}
211211
return true;
@@ -399,7 +399,7 @@ public function __construct($config, $session) {
399399
if (!$this->check_redis($config) && !$this->check_memcache($config)) {
400400
$this->check_session($config);
401401
}
402-
Hm_Debug::add(sprintf('CACHE backend using: %s', $this->type));
402+
Hm_Debug::add(sprintf('CACHE backend using: %s', $this->type), 'info');
403403
}
404404

405405
/**
@@ -454,16 +454,16 @@ protected function check_memcache($config) {
454454
protected function log($key, $msg_type) {
455455
switch ($msg_type) {
456456
case 'save':
457-
Hm_Debug::add(sprintf('CACHE: saving "%s" using %s', $key, $this->type));
457+
Hm_Debug::add(sprintf('CACHE: saving "%s" using %s', $key, $this->type), 'info');
458458
break;
459459
case 'hit':
460-
Hm_Debug::add(sprintf('CACHE: hit for "%s" using %s', $key, $this->type));
460+
Hm_Debug::add(sprintf('CACHE: hit for "%s" using %s', $key, $this->type), 'info');
461461
break;
462462
case 'miss':
463-
Hm_Debug::add(sprintf('CACHE: miss for "%s" using %s', $key, $this->type));
463+
Hm_Debug::add(sprintf('CACHE: miss for "%s" using %s', $key, $this->type), 'warning');
464464
break;
465465
case 'del':
466-
Hm_Debug::add(sprintf('CACHE: deleting "%s" using %s', $key, $this->type));
466+
Hm_Debug::add(sprintf('CACHE: deleting "%s" using %s', $key, $this->type), 'info');
467467
break;
468468
}
469469
}
@@ -633,7 +633,7 @@ public function __construct($config, $session) {
633633
*/
634634
public function setup_cache() {
635635
$cache_class = $this->get_cache_class();
636-
Hm_Debug::add(sprintf('Using %s for cache', $cache_class));
636+
Hm_Debug::add(sprintf('Using %s for cache', $cache_class), 'info');
637637
return new $cache_class($this->config, $this->session);
638638
}
639639

lib/config.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ public function __construct($config) {
338338
*/
339339
private function new_settings($username) {
340340
$res = Hm_DB::execute($this->dbh, 'insert into hm_user_settings values(?,?)', [$username, '']);
341-
Hm_Debug::add(sprintf("created new row in hm_user_settings for %s", $username));
341+
Hm_Debug::add(sprintf("created new row in hm_user_settings for %s", $username), 'success');
342342
$this->config = [];
343343
return $res ? true : false;
344344
}
@@ -417,7 +417,7 @@ public function save($username, $key) {
417417
$this->connect();
418418
if (Hm_DB::execute($this->dbh, 'select settings from hm_user_settings where username=?', [$username])) {
419419
Hm_DB::execute($this->dbh, 'update hm_user_settings set settings=? where username=?', [$config, $username]);
420-
Hm_Debug::add(sprintf("Saved user data to DB for %s", $username));
420+
Hm_Debug::add(sprintf("Saved user data to DB for %s", $username), 'success');
421421
$res = true;
422422
} else {
423423
$res = Hm_DB::execute($this->dbh, 'insert into hm_user_settings values(?,?)', [$username, $config]);
@@ -518,19 +518,19 @@ function load_user_config_object($config) {
518518
switch ($type) {
519519
case 'DB':
520520
$user_config = new Hm_User_Config_DB($config);
521-
Hm_Debug::add("Using DB user configuration");
521+
Hm_Debug::add("Using DB user configuration", 'info');
522522
break;
523523
case 'custom':
524524
if (class_exists($class)) {
525525
$user_config = new $class($config);
526-
Hm_Debug::add("Using custom user configuration: {$class}");
526+
Hm_Debug::add("Using custom user configuration: {$class}", 'info');
527527
break;
528528
} else {
529529
Hm_Debug::add("User configuration class does not exist: {$class}");
530530
}
531531
default:
532532
$user_config = new Hm_User_Config_File($config);
533-
Hm_Debug::add("Using file based user configuration");
533+
Hm_Debug::add("Using file based user configuration", "info");
534534
break;
535535
}
536536
return $user_config;

lib/db.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ static public function connect($site_config) {
146146
self::$dbh[$key] = new PDO($dsn, self::$config['db_user'], self::$config['db_pass']);
147147
self::$dbh[$key]->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
148148
self::$dbh[$key]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
149-
Hm_Debug::add(sprintf('Connecting to dsn: %s', $dsn));
149+
Hm_Debug::add(sprintf('Connecting to dsn: %s', $dsn), "info");
150150
return self::$dbh[$key];
151151
} catch (Exception $oops) {
152152
Hm_Debug::add($oops->getMessage());

lib/dispatch.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,12 @@ public function unpack_messages($request, $session) {
130130
*/
131131
static public function page_redirect($url, $status = false) {
132132
if (DEBUG_MODE) {
133-
Hm_Debug::add(sprintf('Redirecting to %s', $url));
133+
Hm_Debug::add(sprintf('Redirecting to %s', $url), 'info');
134134
Hm_Debug::load_page_stats();
135135
Hm_Debug::show();
136136
}
137137
if ($status == 303) {
138-
Hm_Debug::add('Redirect loop found');
138+
Hm_Debug::add('Redirect loop found', 'warning');
139139
Hm_Functions::cease('Redirect loop discovered');
140140
}
141141
Hm_Functions::header('HTTP/1.1 303 Found');
@@ -197,7 +197,7 @@ private function load_site_lib() {
197197
return;
198198
}
199199
if (is_readable(APP_PATH.'modules/site/lib.php')) {
200-
Hm_Debug::add('Including site module set lib.php');
200+
Hm_Debug::add('Including site module set lib.php', 'info');
201201
require APP_PATH.'modules/site/lib.php';
202202
}
203203
}
@@ -337,7 +337,7 @@ public function get_page($filters, $request) {
337337
$this->page = 'home';
338338
}
339339
$this->module_exec->page = $this->page;
340-
Hm_Debug::add('Page ID: '.$this->page);
340+
Hm_Debug::add('Page ID: '.$this->page, 'info');
341341
}
342342

343343
/**

lib/framework.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class Hm_Functions {
7272
*/
7373
public static function setcookie($name, $value, $lifetime = 0, $path = '', $domain = '', $secure = false, $html_only = false, $same_site = 'Strict') {
7474
$prefix = ($lifetime != 0 && $lifetime < time()) ? 'Deleting' : 'Setting';
75-
Hm_Debug::add(sprintf('%s cookie: name: %s, lifetime: %s, path: %s, domain: %s, secure: %s, html_only %s',$prefix, $name, $lifetime, $path, $domain, $secure, $html_only));
75+
Hm_Debug::add(sprintf('%s cookie: name: %s, lifetime: %s, path: %s, domain: %s, secure: %s, html_only %s',$prefix, $name, $lifetime, $path, $domain, $secure, $html_only), 'info');
7676
return setcookie($name, $value, [
7777
'expires' => $lifetime,
7878
'path' => $path,
@@ -265,7 +265,7 @@ function hm_exists($name) {
265265
$caller = array_shift($bt);
266266
$module = hm_get_module_from_path($caller['file']);
267267
if (function_exists($name)) {
268-
Hm_Debug::add(sprintf('Function in %s replaced: %s', $module, $name));
268+
Hm_Debug::add(sprintf('Function in %s replaced: %s', $module, $name), 'warning');
269269
return true;
270270
}
271271
return false;

lib/module.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public function get($name, $default = NULL, $typed = true) {
146146
$val = $this->output[$name];
147147
if (!is_null($default) && $typed) {
148148
if (gettype($default) != gettype($val)) {
149-
Hm_Debug::add(sprintf('TYPE CONVERSION: %s to %s for %s', gettype($val), gettype($default), $name));
149+
Hm_Debug::add(sprintf('TYPE CONVERSION: %s to %s for %s', gettype($val), gettype($default), $name), 'info');
150150
settype($val, gettype($default));
151151
}
152152
}
@@ -499,7 +499,7 @@ public function trans($string) {
499499
}
500500
}
501501
else {
502-
Hm_Debug::add(sprintf('TRANSLATION NOT FOUND :%s:', $string));
502+
Hm_Debug::add(sprintf('TRANSLATION NOT FOUND :%s:', $string), 'warning');
503503
}
504504
return str_replace('\n', '<br />', strip_tags($string));
505505
}

lib/modules.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public static function add($page, $module, $logged_in, $marker=false, $placement
179179
self::add_page($page);
180180

181181
if (array_key_exists($module, self::$module_list[$page])) {
182-
Hm_Debug::add(sprintf("Already registered module for %s re-attempted: %s", $page, $module));
182+
Hm_Debug::add(sprintf("Already registered module for %s re-attempted: %s", $page, $module), 'warning');
183183
return true;
184184
}
185185
$source === false ? $source = self::$source : false;

lib/output.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,13 @@ class Hm_Debug {
134134

135135
use Hm_List;
136136

137+
/**
138+
* @override
139+
*/
140+
public static function add($string, $type = 'danger') {
141+
Hm_List::add($string, $type);
142+
}
143+
137144
/**
138145
* Add page execution stats to the Hm_Debug list
139146
* @return void

lib/request.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ public function __construct($filters, $config) {
8484
if (!$config->get('disable_empty_superglobals', false)) {
8585
$this->empty_super_globals();
8686
}
87-
Hm_Debug::add('Using sapi: '.$this->sapi);
88-
Hm_Debug::add('Request type: '.$this->type);
89-
Hm_Debug::add('Request path: '.$this->path);
90-
Hm_Debug::add('TLS request: '.intval($this->tls));
91-
Hm_Debug::add('Mobile request: '.intval($this->mobile));
87+
Hm_Debug::add('Using sapi: '.$this->sapi, 'info');
88+
Hm_Debug::add('Request type: '.$this->type, 'info');
89+
Hm_Debug::add('Request path: '.$this->path, 'info');
90+
Hm_Debug::add('TLS request: '.intval($this->tls), 'info');
91+
Hm_Debug::add('Mobile request: '.intval($this->mobile), 'info');
9292
}
9393

9494
/**

lib/session_base.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ public function setup_session() {
403403
if (!Hm_Functions::class_exists($auth_class)) {
404404
Hm_Functions::cease('Invalid auth configuration');
405405
}
406-
Hm_Debug::add(sprintf('Using %s with %s', $session_class, $auth_class));
406+
Hm_Debug::add(sprintf('Using %s with %s', $session_class, $auth_class), 'info');
407407
return new $session_class($this->config, $auth_class);
408408
}
409409

0 commit comments

Comments
 (0)