have LOGF macros add a newline, so user code doesn't need to.

This commit is contained in:
Nils O. Selåsdal
2014-10-06 21:52:28 +02:00
parent 33b48c4276
commit 9bd1336d26
4 changed files with 95 additions and 94 deletions
+5 -4
View File
@@ -305,9 +305,9 @@ void uc_logf(int log_level, int module, int raw,
// to override that by defining UC_DEBUG_ALWAYS
#if defined(DEBUG) || defined(UC_DEBUG_ALWAYS)
# define UC_DEBUGF(mod, fmt, ...)\
uc_logf(UC_LL_DEBUG, mod,0 , UC_SRC_LOCATION, fmt, ## __VA_ARGS__)
uc_logf(UC_LL_DEBUG, mod,0 , UC_SRC_LOCATION, fmt "\n", ## __VA_ARGS__)
# define UC_DEBUGFR(mod, fmt, ...)\
uc_logf(UC_LL_DEBUG, mod,1 , UC_SRC_LOCATION, fmt, ## __VA_ARGS__)
uc_logf(UC_LL_DEBUG, mod,1 , UC_SRC_LOCATION, fmt "\n", ## __VA_ARGS__)
#else
# define UC_DEBUGF(mod, fmt, ...) do {} while (0)
# define UC_DEBUGFR(mod, fmt, ...) do {} while (0)
@@ -317,6 +317,7 @@ void uc_logf(int log_level, int module, int raw,
*
* For log messages with UC_LL_DEBUG, the UC_DEBUGF() macro can be used,
* UC_DEBUGF will only be compiled in if the DEBUG macro is defined
* fmt must be a string literal, and a newline will be added
*
* @param lvl log level of this log message
* @param mod module id of this log messagex.
@@ -324,11 +325,11 @@ void uc_logf(int log_level, int module, int raw,
* @param ... printf style arguments
*/
#define UC_LOGF(lvl, mod, fmt, ...) \
uc_logf(lvl, mod, 0, UC_SRC_LOCATION, fmt, ## __VA_ARGS__)
uc_logf(lvl, mod, 0, UC_SRC_LOCATION, fmt "\n", ## __VA_ARGS__)
/** Raw logging ,Like UC_LOGF, but only prints the supplied
* data, not timestamp, log level etc.
* data, not timestamp, log level, newline, etc.
*/
#define UC_LOGFR(lvl, mod, fmt, ...) \
uc_logf(lvl, mod, 1, UC_SRC_LOCATION, fmt, ## __VA_ARGS__)