Skip to content
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

Add method MsgPastel to MelonLogger #738

Merged
merged 2 commits into from
Sep 15, 2024

Conversation

HAHOOS
Copy link
Contributor

@HAHOOS HAHOOS commented Sep 7, 2024

Adds a new method to MelonLogger called MsgPastel. The name might not make it really clear, but when I was developing a plugin I've come across an issue where the ANSI colors were also written in log files, making the logs less readable. To fix this, I've created a new method for writing messages that uses Regex to remove ANSI from logs. It's the same as Msg with the exception that before writing to file, it runs the following regex: (\x1B|\e|\033)\[(.*?)m to replace all matches with nothing. I'm not quite sure if the \x1B|\e|\033 needs to be there or only one of escape characters, but to be safe I added all of them. Depending on the device running MelonLoader, Regex could slow down the process of logging (from what I have tested, it was ~0.1/0.2 ms on a browser regex tester, but while running ML with regex checking all messages, it looked like there was practically no delay. But I have a pretty good computer so I'm not sure how that would work on slower computers), that's why it's made into a separate method.

I've tested it with a plugin I'm working on that has a lot of ANSI colors and it seems to work well

@HerpDerpinstine HerpDerpinstine merged commit 4e1ae3f into LavaGang:alpha-development Sep 15, 2024
12 checks passed
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