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
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 asMsg
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