Merge branch 'dev-logging' into dev
All checks were successful
Deploy datapack to dev / Build (push) Successful in 8s

This commit is contained in:
themodernhakr 2025-03-26 10:12:20 -05:00
commit 84ddf1c021

View File

@ -1,5 +1,5 @@
@lazy @lazy
function logger(type, caller, message) { function logger(type, caller, message, body) {
$tmp_logger = false; $tmp_logger = false;
$tmp_type = $type; $tmp_type = $type;
if ($temp_type > 6 || $temp_type < 1) { if ($temp_type > 6 || $temp_type < 1) {
@ -20,6 +20,11 @@ function logger(type, caller, message) {
default: default:
return 0; return 0;
} }
$isBody = $body;
if ($isBody) {
return;
}
tellraw @a $body;
} }
class logger { class logger {
@ -41,7 +46,7 @@ class logger {
$logger = false; $logger = false;
} else if ($logger) { } else if ($logger) {
say "Debug 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!"); logger(2, logger, "This is a test. Logging appears to be working as expected!", false);
} 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.";
} }
@ -68,23 +73,23 @@ class logger {
} }
function test_fatal() { function test_fatal() {
logger(5, logger, "This is a test"); logger(5, logger, "This is a test", false);
} }
function test_error() { function test_error() {
logger(4, logger, "This is a test"); logger(4, logger, "This is a test", false);
} }
function test_warning() { function test_warning() {
logger(3, logger, "This is a test"); logger(3, logger, "This is a test", false);
} }
function test_info() { function test_info() {
logger(2, logger, "This is a test"); logger(2, logger, "This is a test", false);
} }
function test_debug() { function test_debug() {
logger(1, logger, "This is a test"); logger(1, logger, "This is a test", false);
} }
} }