diff --git a/.obsidian/workspace.json b/.obsidian/workspace.json index e3b9970..075dcb7 100644 --- a/.obsidian/workspace.json +++ b/.obsidian/workspace.json @@ -97,12 +97,12 @@ "state": { "type": "markdown", "state": { - "file": "Management/User and Admin/Unified Metrics.md", + "file": "Management/Development and Configuration/Datapack/Logging.md", "mode": "source", "source": false }, "icon": "lucide-file", - "title": "Unified Metrics" + "title": "Logging" } } ], @@ -266,6 +266,9 @@ }, "active": "f26c718e97d69090", "lastOpenFiles": [ + "Management/User and Admin/Unified Metrics.md", + "Management/Development and Configuration/Datapack/Logging.md", + "Management/Development and Configuration/Datapack", "Management/User and Admin/Player Analytics (PLAN).md", "Management/User and Admin/Ferdinland Website.md", "Management/User and Admin/Ferdinland Lore Site.md", @@ -274,7 +277,6 @@ "Management/index.md", "index.md", "users", - "Management/User and Admin/Unified Metrics.md", "Management/Development and Configuration", "Management/Operations and Infrastructure", "Management/User and Admin", diff --git a/Management/Development and Configuration/Datapack/Logging.md b/Management/Development and Configuration/Datapack/Logging.md new file mode 100644 index 0000000..3d31cc9 --- /dev/null +++ b/Management/Development and Configuration/Datapack/Logging.md @@ -0,0 +1,43 @@ +# Usage +## Log Levels +This module has 5 log levels: + +- `FATAL`: (5) Indicates that at least an entire module will need to shut down. Generally indicates the likelihood of data corruption. +- `ERROR`: (4) The requested operation could not be completed, or some other problem that prevents necessary or requested functions from working as intended. +- `WARNING`: (3) Something has or may have gone wrong, but nothing has been prevented from functioning. Warnings should be investigated, but do not require immediate action. +- `INFO`: (2) Informational log ("Did this thing", "Started this process"). Shouldn't be too detailed. +- `DEBUG`: (1) Granular play-by-play useful for troubleshooting errors. More likely to include detailed `body`. + +By default, only levels 3 and up will be output. Debug logging, which displays all levels, can be manually toggled in-game with `function ferdinland:logger/toggle`. + +Each log level has an associated test function which will output: +``` +[]: (logger) This is a test +``` + +The functions are: +- `ferdinland:logger/test_fatal` +- `ferdinland:logger/test_error` +- `ferdinland:logger/test_warning` +- `ferdinland:logger/test_info` +- `ferdinland:logger/test_debug` +## Syntax +The module uses the following syntax: +```ts +logger(type, caller, message, body) +``` + +`type` takes an integer from `1` to `5`, corresponding to the associated log level. + +`caller` takes an unquoted string. This should reflect the function triggering the log message: `module.path.to.function`. + +`message` takes a quoted string or an NBT storage location. NBT storage should be in standard JMC format (`::path.to.element`). *Only* paths beginning with `::` with be processed as storages. `@e[tag=entity]::path.to.element` will be processed as a string. + +The content of `message` will be output in a `say` command, and will be visible in the server console. + +`body` takes a `tellraw` object. It will be output in the command `tellraw @ `. +# Configuring +The log level is set to `3` by default. This can be changed manually in game with the command where `` is replaced with the desired log level: +```vb +scoreboard players set $log_level __variable__ +``` \ No newline at end of file