LCOV - code coverage report
Current view: top level - lib/tdb/test - logging.c (source / functions) Hit Total Coverage
Test: coverage report for master 2f515e9b Lines: 8 9 88.9 %
Date: 2024-04-21 15:09:00 Functions: 1 1 100.0 %

          Line data    Source code
       1             : #include "logging.h"
       2             : #include "tap-interface.h"
       3             : #include <stdarg.h>
       4             : #include <stdlib.h>
       5             : #include <string.h>
       6             : #include <stdio.h>
       7             : 
       8             : bool suppress_logging = false;
       9             : const char *log_prefix = "";
      10             : 
      11             : /* Turn log messages into tap diag messages. */
      12        3885 : static void taplog(struct tdb_context *tdb,
      13             :                    enum tdb_debug_level level,
      14             :                    const char *fmt, ...)
      15             : {
      16             :         va_list ap;
      17             :         char line[200];
      18             : 
      19        3885 :         if (suppress_logging)
      20         270 :                 return;
      21             : 
      22        3615 :         va_start(ap, fmt);
      23        3615 :         vsprintf(line, fmt, ap);
      24        3615 :         va_end(ap);
      25             : 
      26             :         /* Strip trailing \n: diag adds it. */
      27        3615 :         if (line[0] && line[strlen(line)-1] == '\n')
      28        3615 :                 diag("%s%.*s", log_prefix, (unsigned)strlen(line)-1, line);
      29             :         else
      30           0 :                 diag("%s%s", log_prefix, line);
      31             : }
      32             : 
      33             : struct tdb_logging_context taplogctx = { taplog, NULL };

Generated by: LCOV version 1.14