Allow logging to take storages as message inputs
All checks were successful
Deploy datapack to dev / Build (push) Successful in 7s
All checks were successful
Deploy datapack to dev / Build (push) Successful in 7s
Message inputs with a leading "::" will be parsed as storages. All other message inputs will be parsed as strings.
This commit is contained in:
parent
31f616e110
commit
915988215d
@ -1,11 +1,26 @@
|
||||
@lazy
|
||||
function logger(type, caller, message, body) {
|
||||
$tmp_logger = false;
|
||||
$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.";
|
||||
function messagePrinter(name, caller, message) {
|
||||
::tmp.string = $message;
|
||||
::tmp.sub = ::tmp.string[0:1];
|
||||
if (String.isEqual("ferdinland:ferdinland", "tmp.sub", "::")) {
|
||||
::temp.message = ::tmp.string[2:];
|
||||
execute run {
|
||||
switch($tmp_logger) {
|
||||
case 5:
|
||||
say "FATAL: ($caller) $(message)";
|
||||
case 4:
|
||||
say "ERROR: ($caller) $(message)";
|
||||
case 3:
|
||||
say "WARNING: ($caller) $(message)";
|
||||
case 2:
|
||||
say "INFO: ($caller) $(message)";
|
||||
case 1:
|
||||
say "DEBUG: ($caller) $(message)";
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
if ($temp_type >= $log_level || $logger) { $tmp_logger = $type; }
|
||||
} with ::temp;
|
||||
} else {
|
||||
switch($tmp_logger) {
|
||||
case 5:
|
||||
say "FATAL: ($caller) $message";
|
||||
@ -20,11 +35,28 @@ function logger(type, caller, message, body) {
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@lazy
|
||||
function logger(type, caller, message, body) {
|
||||
$tmp_logger = false;
|
||||
$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; }
|
||||
|
||||
if (!$tmp_logger) {
|
||||
return;
|
||||
} else {
|
||||
messagePrinter($type, $caller, $message);
|
||||
|
||||
$isBody = $body;
|
||||
if ($isBody) {
|
||||
return;
|
||||
}
|
||||
tellraw @a $body;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class logger {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user