-
Notifications
You must be signed in to change notification settings - Fork 9
/
blzlib_log.c
36 lines (29 loc) · 761 Bytes
/
blzlib_log.c
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
/*
* blzlib - Copyright (C) 2019-2022 Bruno Randolf ([email protected])
*
* This source code is licensed under the GNU Lesser General Public License,
* Version 3. See the file COPYING for more details.
*/
#include <stdarg.h>
#include <stdio.h>
#include "blzlib_log.h"
static void (*log_handler)(enum loglevel ll, const char* fmt, va_list ap);
void __attribute__((format(printf, 2, 3)))
blz_log_out(enum loglevel level, const char* format, ...)
{
va_list args;
va_start(args, format);
if (log_handler != NULL) {
log_handler(level, format, args);
va_end(args);
return;
}
vprintf(format, args);
printf("\n");
va_end(args);
}
void blz_set_log_handler(void (*cb)(enum loglevel ll, const char* fmt,
va_list ap))
{
log_handler = cb;
}