summaryrefslogtreecommitdiff
path: root/libmultipath/debug.c
blob: d30517dfc4dcf97eb077d6ca2dfeb3b6326682db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
 * Copyright (c) 2005 Christophe Varoqui
 */
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>

#include "log_pthread.h"
#include <sys/types.h>
#include <time.h>

#include "vector.h"
#include "config.h"

void dlog (int sink, int prio, const char * fmt, ...)
{
	va_list ap;
	int thres;

	va_start(ap, fmt);
	thres = (conf) ? conf->verbosity : 0;

	if (prio <= thres) {
		if (!sink) {
			time_t t = time(NULL);
			struct tm *tb = localtime(&t);
			char buff[16];

			strftime(buff, sizeof(buff), "%b %d %H:%M:%S", tb);
			buff[sizeof(buff)-1] = '\0';

			fprintf(stdout, "%s | ", buff);
			vfprintf(stdout, fmt, ap);
		}
		else
			log_safe(prio + 3, fmt, ap);
	}
	va_end(ap);
}