Re: Logging with a string via %s
toggle quoted messageShow quoted text
For an operating system that aims to support various functional safety certifications, asynchronous rendering of %s is a terrible idea.
I think %s capability should be dropped from the logger’s format string processing and a separate API added specifically to log a C string, which makes an immediate
From: devel@... [mailto:devel@...]
On Behalf Of pawel.dunaj@...
Sent: Friday, May 17, 2019 1:16 AM
Subject: Re: [Zephyr-devel] Logging with a string via %s
To optimize time of log processing message construction is deferred. For this reason you cannot use arrays that will not live long enough for logger thread to see them.
In other words you can always use static arrays (like you do when calling `LOG_xyz("%s", "testme")`) but you must never pass anything from the stack (like in your example). You can enable `CONFIG_LOG_IMMEDIATE` but this will affect logging performance and does
not actually tells you why the problem happened in the first place.
If you need to print array declared on stack you must call ` log_strdup()` to duplicate it.
Personally I am against this API and I indicated it will cause bugs as people do expect `%s` to simply output a string and they also don't read documentation for something that should just work.
But at least it makes logger faster if you look from the bright side.
Join email@example.com to automatically receive all group messages.