Compare commits

...

10 Commits

Author SHA1 Message Date
b6e1d224e5 Fix debug logging messages 2025-03-11 19:55:30 -05:00
9117c84653 Enable debug logging to bypass log level 2025-03-11 19:55:30 -05:00
7bfa12b539 Turn line into macro command 2025-03-11 19:55:30 -05:00
d30418d57a Fix log level message to display current log level 2025-03-11 19:55:30 -05:00
accd746389 Change logger type check to use temp var 2025-03-11 19:55:30 -05:00
cf55f238ff Add logger error for invalid type paramater 2025-03-11 19:55:30 -05:00
68d4b8c25d 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.
2025-03-11 19:55:30 -05:00
686592df33 Add double-quotes back to log messages
Double-quotes were initially removed for aesthetic reasons. However, JMC
collapses whitespace, resulting in mangled message output. Double quotes
are converted to single quotes in compliled output.
2025-03-11 19:55:30 -05:00
28d85c4e02 Remove double-quotes from log messages 2025-03-11 19:55:30 -05:00
5468fa9605 Add "caller" paramteter to logger 2025-03-11 19:55:30 -05:00

View File

@ -1,18 +1,22 @@
@lazy @lazy
function logger(type, message) { function logger(type, caller, message) {
$tmp_logger = false; $tmp_logger = false;
if ($logger) { $tmp_logger = $type; } $tmp_type = $type;
if ($temp_type > 6 || $temp_type < 1) {
say "The log type requested does not exist. Please find the caller ($caller) and resolve this issue.";
}
if ($temp_type >= $log_level || $logger) { $tmp_logger = $type; }
switch($tmp_logger) { switch($tmp_logger) {
case 5: case 5:
say "FATAL: $message"; say "FATAL: ($caller) $message";
case 4: case 4:
say "ERROR: $message"; say "ERROR: ($caller) $message";
case 3: case 3:
say "WARNING: $message"; say "WARNING: ($caller) $message";
case 2: case 2:
say "INFO: $message"; say "INFO: ($caller) $message";
case 1: case 1:
say "DEBUG: $message"; say "DEBUG: ($caller) $message";
default: default:
return 0; return 0;
} }
@ -21,11 +25,23 @@ function logger(type, message) {
class logger { class logger {
@add(__load__) @add(__load__)
function __init__() { 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;
}
execute run {
$say "The log level is set to $(0).";
} with [$log_level];
if (!$logger) { if (!$logger) {
$logger = false; $logger = false;
} else if ($logger) { } 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, "This is a test. Logging appears to be working as expected!"); logger(2, logger, "This is a test. Logging appears to be working as expected!");
} else { } 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."; 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.";
} }
@ -45,30 +61,30 @@ class logger {
function status() { function status() {
switch($logger) { switch($logger) {
case 0: case 0:
say "Logging is disabled"; say "Debug logging is disabled";
case 1: case 1:
say "Logging is enabled"; say "Debug logging is enabled";
} }
} }
function test_fatal() { function test_fatal() {
logger(5, "This is a test"); logger(5, logger, "This is a test");
} }
function test_error() { function test_error() {
logger(4, "This is a test"); logger(4, logger, "This is a test");
} }
function test_warning() { function test_warning() {
logger(3, "This is a test"); logger(3, logger, "This is a test");
} }
function test_info() { function test_info() {
logger(2, "This is a test"); logger(2, logger, "This is a test");
} }
function test_debug() { function test_debug() {
logger(1, "This is a test"); logger(1, logger, "This is a test");
} }
} }