Skip to content

Improve script logging #115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

tal5
Copy link
Member

@tal5 tal5 commented Jul 18, 2025

No description provided.


private static ParseableTag fromFormatScriptOrParse(String rawFormat, ScriptContainer owner) {
FormatScriptContainer formatScript = ScriptRegistry.getScriptContainerAs(rawFormat, FormatScriptContainer.class);
return formatScript != null && formatScript.getFormatTag() != null ? formatScript.getFormatTag() : TagManager.parseTextToTag(rawFormat, DenizenCore.implementation.getTagContext(owner));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is such a cursed way of differentiating two types of input.

If I input eg my_project_errar then any errors are gonna log my_project_errar because I made a typo, and I won't notice that typo til I happen to have an error in the script.

Ideally there'd be some more explicit, like, error_script: vs error: or something so if error_script is set but invalid it immediately logs an error during reload

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that was mostly an early throw-together format, changed it into the vision™ (you can now register format types, which means we could maybe add support for this in narrate, announce, etc. later on) with split keys for raw/script formats - lmk if that looks good.

// @name Script Logging Format
// @group Script Container System
// @description
// Script logging contexts provide the format certain commands will use for their texts.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This meta should probably have a Most notably, this includes <@link command debug>

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added, and clarified the format a bit in general.

@@ -33,19 +37,17 @@ public DebugCommand() {
// Use to quickly output debug information to console.
//
// Valid types include:
// DEBUG: standard hideable debug.
// DEBUG: standard hideable debug, supports <@link language Script Logging Formats> (in which case it isn't hideable).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's not standard hideable debug, it should be a separate type. ScriptDebug or something, idk.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a default OUTPUT enum value for this (lmk if the name is good, not sure honestly), but documenting it as an option felt weird, so I ended up documenting it as basically an optional arg that just technically defaults to OUTPUT in the background, but can change it if preferred.

@@ -59,6 +60,8 @@ public class ScriptContainer implements Debuggable {
//
// -->

ScriptLoggingContext loggingContext;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be public

@@ -15,7 +27,7 @@ public void addDefinition(String definition, ObjectTag value) {

@Override
public void addDefinition(String definition, String value) {
addDefinition(definition, new ElementTag(value));
addDefinition(definition, new ElementTag(value, true));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noope. This is not in fact plaintext, this is for raw unparsed data.

private final MapTag definitions;

public SimpleDefinitionProvider(MapTag map) {
this.definitions = map;
Copy link
Member

@mcmonkey4eva mcmonkey4eva Jul 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thaaat's dangerous. This constructor should make a copy of the map, not track the original instance directly (ie the caller shouldn't have to do its own copy as you do below)

@tal5 tal5 marked this pull request as ready for review July 21, 2025 15:07
import java.util.Map;
import java.util.Set;

public record ScriptLoggingContext(Map<Key, ParseableTag> formats, ParseableTag singleFormat) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this a record

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No specific reason, records are just an easy "Hey java, give me an object with these fields and a ready constructor and equals and everything" - afaics making this a class would just be more lines of code, no? as it never needs to be modified anyway

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants