toggle quoted messageShow quoted text
There’s also a log_strdup() API to deal with this issue.
On 15 May 2019, at 14.27, Stefan Jaritz <firstname.lastname@example.org> wrote:
Depending on you logging setup, the log of the string is done inside the "LOG_DBG" command or later.
Later means, that your main function was already left and your local variables are gone = invalid.
Try to add following lines at your proj.conf:
This will force the logger "execute" the log function.
On 15/05/2019 11:52, lairdjm wrote:
I’m seeing an issue whereby I am unable to log strings using LOG_DBG() and %s format, for a quick example I modified the hello world sample to enable logging and change the code to this:
#define LOG_DOMAIN test_domain
LOG_DBG("Test : %s", baTmpBuf);
printk("Hello World! %s\n", CONFIG_BOARD);
I expect to see “Test : ffffffff” but instead I am getting “Test : %*”, if I change the code to inefficiently log each character, e.g.:
LOG_DBG("Test : %c%c%c%c%c%c%c%c", baTmpBuf, baTmpBuf, baTmpBuf, baTmpBuf, baTmpBuf, baTmpBuf,baTmpBuf, baTmpBuf);
Then I get the expected output: “Test : ffffffff”
So why is %s not outputting a string? If there a configuration option I have missed? I have tried toggling “Format strings with libc” option but it doesn’t change anything. I’m testing on an nRF52840 using the nrf52840_pca10056 board file.
THIS MESSAGE, ANY ATTACHMENT(S), AND THE INFORMATION CONTAINED HEREIN MAY BE PROPRIETARY TO LAIRD CONNECTIVITY, INC. AND/OR ANOTHER PARTY, AND MAY FURTHER BE INTENDED TO BE KEPT CONFIDENTIAL. IF YOU ARE NOT THE INTENDED RECIPIENT, PLEASE DELETE THE EMAIL AND ANY ATTACHMENTS, AND IMMEDIATELY NOTIFY THE SENDER BY RETURN EMAIL. THIS MESSAGE AND ITS CONTENTS ARE THE PROPERTY OF LAIRD CONNECTIVITY, INC. AND MAY NOT BE REPRODUCED OR USED WITHOUT THE EXPRESS WRITTEN CONSENT OF LAIRD CONNECTIVITY, INC.