multipath-tools: add alias_prefix to multipath.conf.5
[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
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         thres = (conf) ? conf->verbosity : 0;
24         put_multipath_config(conf);
25
26         if (prio <= thres) {
27                 if (sink < 1) {
28                         if (sink == 0) {
29                                 time_t t = time(NULL);
30                                 struct tm *tb = localtime(&t);
31                                 char buff[16];
32
33                                 strftime(buff, sizeof(buff),
34                                          "%b %d %H:%M:%S", tb);
35                                 buff[sizeof(buff)-1] = '\0';
36
37                                 fprintf(stdout, "%s | ", buff);
38                         }
39                         vfprintf(stdout, fmt, ap);
40                 }
41                 else
42                         log_safe(prio + 3, fmt, ap);
43         }
44         va_end(ap);
45 }