Extend the logging module to support custom module prefix

This commit is contained in:
Niclas Finne 2017-11-30 15:20:52 +01:00
parent 0e93d1da9c
commit 11b50009e9
2 changed files with 8 additions and 1 deletions

View File

@ -81,6 +81,13 @@
#define LOG_OUTPUT(...) printf(__VA_ARGS__)
#endif /* LOG_CONF_OUTPUT */
/* Custom log prefix output function -- default is LOG_OUTPUT */
#ifdef LOG_CONF_OUTPUT_PREFIX
#define LOG_OUTPUT_PREFIX(level, levelstr, module) LOG_CONF_OUTPUT_PREFIX(level, levelstr, module)
#else /* LOG_CONF_OUTPUT_PREFIX */
#define LOG_OUTPUT_PREFIX(level, levelstr, module) LOG_OUTPUT("[%-4s: %-10s] ", levelstr, module)
#endif /* LOG_CONF_OUTPUT_PREFIX */
/******************************************************************************/
/********************* A list of currently supported modules ******************/
/******************************************************************************/

View File

@ -101,7 +101,7 @@ extern struct log_module all_modules[];
if(level <= (LOG_LEVEL)) { \
if(newline) { \
if(LOG_WITH_MODULE_PREFIX) { \
LOG_OUTPUT("[%-4s: %-10s] ", levelstr, LOG_MODULE); \
LOG_OUTPUT_PREFIX(level, levelstr, LOG_MODULE); \
} \
if(LOG_WITH_LOC) { \
LOG_OUTPUT("[%s: %d] ", __FILE__, __LINE__); \