Impletement print-like function using NRF_LOG

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:

int mylog(const char *format, ...)
{
    NRF_LOG_RAW_INFO("%s (%d%s: ""I", __LINE__, "MyPrintf");
    NRF_LOG_RAW_INFO(format);
    NRF_LOG_RAW_INFO("\n");
    return 0;
}
Some code to test it:
mylog("My printf success!"); It print well;
mylog("My printf success with num%d!", 50); num doesn't equal to 50, something went wrong.
Anyone know how to achieve this? 
Thank you!
Young
Parents Reply Children
No Data
Related