summaryrefslogtreecommitdiff
path: root/classes/debug.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2022-06-10 13:39:00 +0300
committerAndrew Dolgov <[email protected]>2022-06-10 13:39:00 +0300
commitcf1eaeedf3026948cf2210af1c747bdc3522d6ff (patch)
tree31780f12fb075b6b37be7a8f2fb813ba9db4980a /classes/debug.php
parent2975c7297b680e486f326939b9fba82d8cf18035 (diff)
* add UserHelper methods to manipulate user database (add, modify, delete)
* expose said methods via CLI (update.php) * fix several invocations of deprecated functions * set stricter type hints on several method arguments
Diffstat (limited to 'classes/debug.php')
-rw-r--r--classes/debug.php20
1 files changed, 17 insertions, 3 deletions
diff --git a/classes/debug.php b/classes/debug.php
index fbdf260e0..4777e8c74 100644
--- a/classes/debug.php
+++ b/classes/debug.php
@@ -68,9 +68,9 @@ class Debug {
}
/**
- * @param int $level Debug::LOG_*
+ * @param Debug::LOG_* $level
*/
- public static function set_loglevel(int $level): void {
+ public static function set_loglevel($level): void {
self::$loglevel = $level;
}
@@ -82,7 +82,21 @@ class Debug {
}
/**
- * @param int $level Debug::LOG_*
+ * @param int $level integer loglevel value
+ * @return Debug::LOG_* if valid, warn and return LOG_DISABLED otherwise
+ */
+ public static function map_loglevel(int $level) : int {
+ if (in_array($level, self::ALL_LOG_LEVELS)) {
+ /** @phpstan-ignore-next-line */
+ return $level;
+ } else {
+ user_error("Passed invalid debug log level: $level", E_USER_WARNING);
+ return self::LOG_DISABLED;
+ }
+ }
+
+ /**
+ * @param Debug::LOG_* $level log level
*/
public static function log(string $message, int $level = Debug::LOG_NORMAL): bool {