Add a newline to log messages at macro expansion

This simplifies building the log output because it means we don't have
to malloc a buffer to append a newline, and we keep the atomic write
property we're after.  It also takes advantage of the C constant string
concatenation which we already require to work to prepend the thread and
pid data.
This commit is contained in:
Alex Young
2012-07-13 12:18:19 +01:00
parent 9f4da5def0
commit 15109c72d1
2 changed files with 5 additions and 19 deletions

View File

@@ -87,7 +87,7 @@ void mylog(int line_level, const char* format, ...);
#define levstr(i) (i==0?'D':(i==1?'I':(i==2?'W':(i==3?'E':'F'))))
#define myloglev(level, msg, ...) mylog( level, "%c:%d %p %s:%d: "msg, levstr(level), getpid(),pthread_self(), __FILE__, __LINE__, ##__VA_ARGS__ )
#define myloglev(level, msg, ...) mylog( level, "%c:%d %p %s:%d: "msg"\n", levstr(level), getpid(),pthread_self(), __FILE__, __LINE__, ##__VA_ARGS__ )
#ifdef DEBUG
# define debug(msg, ...) myloglev(0, msg, ##__VA_ARGS__)