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