# HG changeset patch # User Sebastien Decugis # Date 1370016905 -7200 # Node ID eaa92af9e46d9f57a3dae263b7b4d02d631813fb # Parent 5b930daeb4c13a4ccfa5a8113ca1c0e533348716 New macro LOG_SPLIT to allow dumping multi-line buffers with prefix and suffix diff -r 5b930daeb4c1 -r eaa92af9e46d include/freeDiameter/libfdproto.h --- a/include/freeDiameter/libfdproto.h Fri May 31 17:47:36 2013 +0200 +++ b/include/freeDiameter/libfdproto.h Fri May 31 18:15:05 2013 +0200 @@ -347,6 +347,17 @@ (prefix), __strbuf, (suffix)); \ } +/* Split a multi-line buffer into separate calls to the LOG function. */ +#define LOG_SPLIT(printlevel, per_line_prefix, mlbuf, per_line_suffix ) { \ + char * __line = (mlbuf), *__next; \ + char * __p = (per_line_prefix), *__s = (per_line_suffix); \ + while ((__next = strchr(__line, '\n')) != NULL) { \ + LOG(printlevel, "%s%.*s%s", __p ?:"", __next - __line, __line, __s ?:""); \ + __line = __next + 1; \ + } \ + LOG(printlevel, "%s%s%s", __p ?:"", __line, __s ?:""); \ +} + /* Helper for function entry -- for very detailed trace of the execution */ #define TRACE_ENTRY(_format,_args... ) \ LOG_A("[enter] %s(" _format ") {" #_args "}", __PRETTY_FUNCTION__, ##_args ); diff -r 5b930daeb4c1 -r eaa92af9e46d libfdcore/core.c --- a/libfdcore/core.c Fri May 31 17:47:36 2013 +0200 +++ b/libfdcore/core.c Fri May 31 18:15:05 2013 +0200 @@ -250,11 +250,11 @@ /* Display configuration */ b = fd_conf_dump(&buf, &len, NULL); - LOG_N("%s", b ?: "Error during configuration dump..."); + LOG_SPLIT(FD_LOG_NOTICE, NULL, b ?: "", NULL); /* Display extensions status */ b = fd_ext_dump(&buf, &len, NULL, 19); - LOG_N("Loaded extensions: %s", b ?: "Error during extensions dump..."); + LOG_SPLIT(FD_LOG_NOTICE, "Loaded extensions: ", b?:"", NULL); /* Display registered triggers for FDEV_TRIGGER */ b = fd_event_trig_dump(&buf, &len, &offset);