I need to define a function to print message and register to other module. In my application, NRF_LOG is used by most modules so I need to use NRF_LOG to construct this printf-like function.
Belowed is code:
I need to define a function to print message and register to other module. In my application, NRF_LOG is used by most modules so I need to use NRF_LOG to construct this printf-like function.
Belowed is code:
Hello Young,
The string is correctly passed to the logger backend here: NRF_LOG_RAW_INFO(format); but without the value argument ('50'). So it is not surprising that it prints an arbitrary value, but what maybe is surprising is that it didn't cause a build error.
Maybe this could be solved by just redefining the logger macro?
e.g.
#define mylog(...) NRF_LOG_INFO(__VA_ARGS__)
...
mylog("My printf success with num%d!", 50);Hi Vidar Berg,
My upper code need to log function to be as a input parameters, like sec_init(sec_log_fun_t cb).
#define mylog(...) NRF_LOG_INFO(__VA_ARGS__) is OK, but how to construct a function?
Sorry, I'm not sure how to integrate logger module with your library. I can try to do it here if you are able to share your code here or in a private support ticket.
typedef int (*secure_log)(const char *format, ...);
struct secure_port_apis_t
{
secure_log log;
};
int secure_port_apis_reg(const struct secure_port_apis_t *apis);
See code above.
Call secure_port_apis_reg() to register APIs. So define log function below:
int sec_log(const char *format, ...)
{
NRF_LOG_RAW_INFO(format);
NRF_LOG_RAW_INFO("\n");
return 0;
}
It does't work well.
Call secure_port_apis_reg() to register APIs. So define log function below:
You are still only passing the format string.
I will need your project if I am going to try it here.