multipathd: fix reservation_key check
[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 #include "defaults.h"
15 #include "debug.h"
16
17 void dlog (int sink, int prio, const char * fmt, ...)
18 {
19         va_list ap;
20         int thres;
21         struct config *conf;
22
23         va_start(ap, fmt);
24         conf = get_multipath_config();
25         ANNOTATE_IGNORE_READS_BEGIN();
26         thres = (conf) ? conf->verbosity : DEFAULT_VERBOSITY;
27         ANNOTATE_IGNORE_READS_END();
28         put_multipath_config(conf);
29
30         if (prio <= thres) {
31                 if (sink < 1) {
32                         if (sink == 0) {
33                                 time_t t = time(NULL);
34                                 struct tm *tb = localtime(&t);
35                                 char buff[16];
36
37                                 strftime(buff, sizeof(buff),
38                                          "%b %d %H:%M:%S", tb);
39                                 buff[sizeof(buff)-1] = '\0';
40
41                                 fprintf(stderr, "%s | ", buff);
42                         }
43                         vfprintf(stderr, fmt, ap);
44                 }
45                 else
46                         log_safe(prio + 3, fmt, ap);
47         }
48         va_end(ap);
49 }