multipath-tools: use internal drd.h file
[multipath-tools/.git] / libmultipath / debug.c
1 /*
2  * Copyright (c) 2005 Christophe Varoqui
3  */
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <stdarg.h>
7
8 #include "log_pthread.h"
9 #include <sys/types.h>
10 #include <time.h>
11 #include "../third-party/valgrind/drd.h"
12 #include "vector.h"
13 #include "config.h"
14
15 void dlog (int sink, int prio, const char * fmt, ...)
16 {
17         va_list ap;
18         int thres;
19         struct config *conf;
20
21         va_start(ap, fmt);
22         conf = get_multipath_config();
23         ANNOTATE_IGNORE_READS_BEGIN();
24         thres = (conf) ? conf->verbosity : 0;
25         ANNOTATE_IGNORE_READS_END();
26         put_multipath_config(conf);
27
28         if (prio <= thres) {
29                 if (sink < 1) {
30                         if (sink == 0) {
31                                 time_t t = time(NULL);
32                                 struct tm *tb = localtime(&t);
33                                 char buff[16];
34
35                                 strftime(buff, sizeof(buff),
36                                          "%b %d %H:%M:%S", tb);
37                                 buff[sizeof(buff)-1] = '\0';
38
39                                 fprintf(stdout, "%s | ", buff);
40                         }
41                         vfprintf(stdout, fmt, ap);
42                 }
43                 else
44                         log_safe(prio + 3, fmt, ap);
45         }
46         va_end(ap);
47 }