Navigation


Changeset 1167:eaa92af9e46d in freeDiameter


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

Files:
2 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
  • libfdcore/core.c

    r1159 r1167  
    251251        /* Display configuration */
    252252        b = fd_conf_dump(&buf, &len, NULL);
    253         LOG_N("%s", b ?: "Error during configuration dump...");
     253        LOG_SPLIT(FD_LOG_NOTICE, NULL, b ?: "<Error during configuration dump...>", NULL);
    254254       
    255255        /* Display extensions status */
    256256        b = fd_ext_dump(&buf, &len, NULL, 19);
    257         LOG_N("Loaded extensions: %s", b ?: "Error during extensions dump...");
     257        LOG_SPLIT(FD_LOG_NOTICE, "Loaded extensions: ", b?:"<Error during extensions dump...>", NULL);
    258258       
    259259        /* Display registered triggers for FDEV_TRIGGER */
Note: See TracChangeset for help on using the changeset viewer.