-
Notifications
You must be signed in to change notification settings - Fork 11
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
Allow color codes to pass the filter but strip the rest control characters #24
Comments
That would pass escape sequences for everyone. This should be done in a third |
I mostly agree.
But at different viewpoint: Disabling (filtering) colors should be responsibility of a log viewer. However since colored logs aren't the default and people don't expect to see color in raw logs, your suggestion of Currently if some program sends colored log lines to logger and if |
They might not be color sequences and removing them could result in missing information. It would be better to ask the program author to stop sending escape sequences in logs. |
Yes. That's certainly a problem. I think your suggestion of adding |
Colors are handy to attract attention to more fatal messages for example.
And I could have color on my metalog created log files by enabling ACCEPT_UNICODE_CONTROL_CHARS.
However it then allows all other control characters to pass.
I saw a simple fix for this by editing a single line, 189, in metalog.h. I edited it to look like this:
# define ISCTRLCODE(X) (((X) == 0x7f || !(((unsigned char) (X)) & 0x60)) && (X) != 0x1B)
0x1B being the escape character which is needed for color codes.
It seems to do the job (at least on version 20220214). Please carefully review the code snippet as I'm no C programmer at all. ;)
EDIT: Currenly if metalog is set to filter out all the control characters then all the color codes (after the escape character) will be left in the logs. Maybe metalog should try to clean color codes too if filter set to filter all control characters?
The text was updated successfully, but these errors were encountered: