Elliptics version update: 2.19.2.8
[elliptics.git] / library / log.c
blob1e3bf4aa04329b29b8de7a2b24c5fff0230a2dba
1 /*
2 * 2008+ Copyright (c) Evgeniy Polyakov <zbr@ioremap.net>
3 * All rights reserved.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
16 #include <sys/types.h>
17 #include <sys/stat.h>
18 #include <sys/socket.h>
19 #include <sys/time.h>
21 #include <sys/syscall.h>
23 #include <errno.h>
24 #include <fcntl.h>
25 #include <netdb.h>
26 #include <stdarg.h>
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <string.h>
30 #include <unistd.h>
31 #include <time.h>
33 #include "elliptics.h"
35 int dnet_log_init(struct dnet_node *n, struct dnet_log *l)
37 if (!n)
38 return -EINVAL;
40 n->log = l;
42 return 0;
45 void dnet_log_raw(struct dnet_node *n, int level, const char *format, ...)
47 va_list args;
48 char buf[1024];
49 struct dnet_log *l = n->log;
50 int buflen = sizeof(buf);
52 if (!l->log || (l->log_level < level))
53 return;
55 va_start(args, format);
56 vsnprintf(buf, buflen, format, args);
57 buf[buflen-1] = '\0';
58 l->log(l->log_private, level, buf);
59 va_end(args);