TelepathicGrunt / Blame

make crashlogs more detailed for certain crashes
GNU Lesser General Public License v3.0
11 stars 1 forks source link

[Request] add system for other mods to selectively suppress warnings/errors #23

Closed supersaiyansubtlety closed 3 years ago

supersaiyansubtlety commented 3 years ago

When using Blame alongside my Dispenser Configurator, I get tons of these errors in my latest.log:

[12:51:41] [Server thread/ERROR]: 
****************** Blame Extra Info Report 1.16.4-2.4.0 ******************
   Ignore this unless item behavior aren't working with Dispensers.
  Dispenser Behavior overridden for minecraft:nether_wart_block
  New behavior: net.minecraft.class_2347
  Old behavior: net.sssubtlety.dispenser_configurator.dispenserBehaviors.GenericDispenserBehavior
  Registration done at: 
    it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap.putAll(Object2ObjectOpenHashMap.java:245)
    net.sssubtlety.dispenser_configurator.dispenserBehaviors.ConfiguratorManager.restoreBehaviors(ConfiguratorManager.java:130)
    net.sssubtlety.dispenser_configurator.DispenserConfiguratorInit.lambda$new$1(DispenserConfiguratorInit.java:37)

Since changing dispenser behaviors is the whole point of my mod, it would be nice if I could tell Blame not to worry dispenser overrides from net.sssubtlety.dispenser_configurator, either ignoring them entirely or compressing/truncating them to a single log print.

I think looking for a blame entrypoint that lets other mods specify a package name and an error category to suppress would be ideal (I'd specify something like "net.sssubtlety.dispenser_configurator" and "Dispenser Behavior overridden").

TelepathicGrunt commented 3 years ago

I don't know how entrypoints work and not even sure how to make one (and I would need Forge parity too for easier maintenance). But what I can do is probably just expose a public method that you call once before you do dispenser stuff, pass in the stacktrace line to look for, and maybe a msg as well. Something like this but not hardcoded. Would that work for you? https://github.com/TelepathicGrunt/Blame/blob/0d8c7ca4021eff6908f7696a3f8192ee8bfe7cca/src/main/java/com/telepathicgrunt/blame/main/DispenserBlockRegistry.java#L36-L46

supersaiyansubtlety commented 3 years ago

Ok, that looks like it would work just as well

TelepathicGrunt commented 3 years ago

commit that addresses this: https://github.com/TelepathicGrunt/Blame/commit/c72ba4e5796c188ea48f65ac8abe2088987987fd The method will be DispenserBlockRegistry.addCondensedMessage but remember, Blame isn't suppose to be on 24/7 so people shouldn't be seeing the logspam that much anyway. it's purely a diagnosis tool and your mod actually would benefit from having Blame print every replacement so that players can see if an behavior that isn't working was caused by your mod. If you do decide to still condense, please try and stuff all affected items into the summaryOfItemsAffected parameter for easier debugging later on.

update will be released in a bit

TelepathicGrunt commented 3 years ago

after talking with some friends and thinking some more, exposing such a method or api endpoint would open up a can of worms of mods inappropriately bypassing Blame's registry replacing reporting. Instead, I'll just hardcode your mod as an exception like I did with quark and generate a condense message that way. Any other mod doing the excessive replacements can contact me directly so I can vet their mod to see if it is reasonable.

For your mod, what items will the registry replacing happen for? What would you like me to say in the message that would help users?

supersaiyansubtlety commented 3 years ago

Fair enough. My mod lets you add dispenser behavior to literally any item, through datapacks.

TelepathicGrunt commented 3 years ago

hmm. that is tricky. It seems the RR only happens with the items that the datapack specifies. On one hand, listing each RR separately might prove very helpful. On the other hand, your example datapack on the curseforge page causes 2000 lines of entry from Blame. I think I'll just tell people to check the datapack folder for your datapack and see what item behavior are modified there for your mod. I think that should be fine.

this is what it will show for your mod now. I hope this is good!

****************** Blame Extra Info Report 1.16.4-2.4.1 ******************
   Condensed Dispenser message mode activated for dispenser_configurator
   Dispenser behavior registry replacement was detected.
   Reason for the change: Dispenser Configurator register replaces the item's dispenser behavior to allow users to change the behavior of any item possible.
   The kinds of items affected: All items specified with Dispenser Configurator's datapack will have their behavior changed. See the world's datapack folder for what item are affected by that mod.
   Ignore this log entry unless block behaviors aren't working with Dispensers for some reason.

And yeah, thank you for pointing this out. I'll try and keep an eye out for other mods that may RR massive amounts of dispenser behaviors as well. v2.4.1 Blame should now condense RR from your mod into one message!

supersaiyansubtlety commented 3 years ago

Looks good, thanks!

supersaiyansubtlety commented 3 years ago

Version 1.1 of Dispenser Configurator eliminates registry replacement, fyi, if you want to add a version check to to the special blame message.

TelepathicGrunt commented 3 years ago

how does it do it? you mean eliminate Dispenser Configurator's own replacements or somehow gathers all mod's behaviors and run them all serially for a block?

supersaiyansubtlety commented 3 years ago

It keeps its own map of dispenser behaviors and makes the dispenser try those behaviors before trying the ones in the registry.