liblogging icon indicating copy to clipboard operation
liblogging copied to clipboard

Add more \xxx escapes to printf implementation

Open rgerhards opened this issue 11 years ago • 5 comments

We currently support a too-small subset. But before we extend it, we should think if we really want to have control characters inside our log messages (or maybe make this a config option?).

rgerhards avatar Feb 20 '14 16:02 rgerhards

I admit I am not even sure if it is a good idea to permit them...

rgerhards avatar Feb 25 '14 13:02 rgerhards

I might support \ooo or \xhhh escapes, so that people who are using a non-ASCII character set can specify non-ASCII characters if required (not necessarily control characters).

spc476 avatar Feb 25 '14 19:02 spc476

Thanks for the suggestion! If you'd like to contribute that code, just send me a patch or pull request. If you have no time, I'll most probably do it some time later this week.

rgerhards avatar Feb 26 '14 07:02 rgerhards

I'm a little unsure what exactly this issue is trying to address. Are you talking about the backslash-escape formatting in __stdlog_sigsafe_printf()? I don't understand why that is even present. If I specify something like:

stdlog(..., "This is a message with embedded newlines specified as hex: \x0a octal: \012 and symbol: \n");

The compiler translates those escapes; __stdlog_sigsafe_printf() will never see them, so there is no need to have "support" for them in that function. In fact, I would be very surprised if I wrote:

stdlog(..., "message with literal backslash-n \\n embedded");

and found that stdlog turned that into a log message like:

message with literal backslash-n 
 embedded

I think that is what the existing code does and that section should be removed.

Am I missing something?

dabright avatar Dec 01 '16 14:12 dabright

IIRC the intent was to actually escape (LF) back to ('','n') so that control characters cannot render the log unreadable.

rgerhards avatar Dec 03 '16 12:12 rgerhards