Add log level threshold
Set default log level to 3, or ERROR. Ensure log level isn't overriden on reload. Add errors if log level is misconfigured.
This commit is contained in:
parent
686592df33
commit
68d4b8c25d
@ -1,7 +1,8 @@
|
||||
@lazy
|
||||
function logger(type, caller, message) {
|
||||
$tmp_logger = false;
|
||||
if ($logger) { $tmp_logger = $type; }
|
||||
$tmp_type = $type;
|
||||
if ($temp_type >= $log_level) { $tmp_logger = $type; }
|
||||
switch($tmp_logger) {
|
||||
case 5:
|
||||
say "FATAL: ($caller) $message";
|
||||
@ -21,10 +22,19 @@ function logger(type, caller, message) {
|
||||
class logger {
|
||||
@add(__load__)
|
||||
function __init__() {
|
||||
if (!$log_level) {
|
||||
$log_level = 3;
|
||||
} else if ($log_level > 5) {
|
||||
say "The log level was too high. Resetting to default value.";
|
||||
$log_level = 3;
|
||||
}
|
||||
|
||||
say "Log level set to '$log_level'.";
|
||||
|
||||
if (!$logger) {
|
||||
$logger = false;
|
||||
} else if ($logger) {
|
||||
say "Logging is enabled. You should now see a test log message:";
|
||||
say "Debug logging is enabled. You should now see a test log message:";
|
||||
logger(2, logger, "This is a test. Logging appears to be working as expected!");
|
||||
} else {
|
||||
say "This is not a log message. There appears to be something wrong with the logger. It has not been detected as `!true` or `true`. Please investigate.";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user