Navigation


Changeset 1167:eaa92af9e46d in freeDiameter for include


Ignore:
Timestamp:
Jun 1, 2013, 1:15:05 AM (11 years ago)
Author:
Sebastien Decugis <sdecugis@freediameter.net>
Branch:
default
Phase:
public
Message:

New macro LOG_SPLIT to allow dumping multi-line buffers with prefix and suffix

File:
1 edited

Legend:

Unmodified
Added
Removed
  • include/freeDiameter/libfdproto.h

    r1164 r1167  
    346346        fd_log(printlevel, STD_TRACE_FMT_STRING "%s%s%s" STD_TRACE_FMT_ARGS,                                            \
    347347               (prefix), __strbuf, (suffix));                                                                           \
     348}
     349
     350/* Split a multi-line buffer into separate calls to the LOG function. */
     351#define LOG_SPLIT(printlevel, per_line_prefix, mlbuf, per_line_suffix ) {                                               \
     352        char * __line = (mlbuf), *__next;                                                                               \
     353        char * __p = (per_line_prefix), *__s = (per_line_suffix);                                                       \
     354        while ((__next = strchr(__line, '\n')) != NULL) {                                                               \
     355                LOG(printlevel, "%s%.*s%s", __p ?:"", __next - __line, __line, __s ?:"");                               \
     356                __line = __next + 1;                                                                                    \
     357        }                                                                                                               \
     358        LOG(printlevel, "%s%s%s", __p ?:"", __line, __s ?:"");                                                          \
    348359}
    349360
Note: See TracChangeset for help on using the changeset viewer.