GDLauncher
GDLauncher copied to clipboard
Clean up Log4J xml-spam
Purpose
Log4J xml-spam has been an issue since the l4j RCE exploit was discovered a while ago. It makes reading logs at runtime harder, if not impossible, for end-users and makes modpack development take longer unnecessarily.
Approach
I'm parsing the raw XML log4j spits out through string manipulation. It's not the most elegant (or fastest) solution, but we're already using console.log, so speed went out the window a while ago, and I don't know nearly enough about regex to use it in a production setting. Future revisions could clean this up, but for now it's functional.
I very specifically decided not to parse messages coming through stderr, because if you're reading error messages you probably know how to sift through xml anyways.
Open Questions and Pre-Merge TODOs
- [x] As far as I know, this should be fully functional for any version of Minecraft. I've used it over the last couple months with 1.16+, 1.7.10, and 1.12.2 - so at least the major modded versions are working.
Learning
All of this was done from memory, it's very simple Vanilla JS. I did the bulk of development in the Electron dev tools, rather than in an actual development environment, because I wasn't originally planning on doing a PR, then decided other people would probably benefit from having this tiny tweak. In the future, I might do an additional PR to clean this up using regex rather than string manipulation, which would involve much more learning, as I don't know nearly enough regex to do something like this.