libfuse

fuse_log.c
1 /*
2 FUSE: Filesystem in Userspace
3 Copyright (C) 2019 Red Hat, Inc.
4
5 Logging API.
6
7 This program can be distributed under the terms of the GNU LGPLv2.
8 See the file COPYING.LIB
9 */
10
11 #include "fuse_log.h"
12
13 #include <stdarg.h>
14 #include <stdio.h>
15
16 static void default_log_func(
17 __attribute__(( unused )) enum fuse_log_level level,
18 const char *fmt, va_list ap)
19 {
20 vfprintf(stderr, fmt, ap);
21 }
22
23 static fuse_log_func_t log_func = default_log_func;
24
25 void fuse_set_log_func(fuse_log_func_t func)
26 {
27 if (!func)
28 func = default_log_func;
29
30 log_func = func;
31 }
32
33 void fuse_log(enum fuse_log_level level, const char *fmt, ...)
34 {
35 va_list ap;
36
37 va_start(ap, fmt);
38 log_func(level, fmt, ap);
39 va_end(ap);
40 }
fuse_log.h
fuse_log
void fuse_log(enum fuse_log_level level, const char *fmt,...)
Definition: fuse_log.c:33
fuse_log_func_t
void(* fuse_log_func_t)(enum fuse_log_level level, const char *fmt, va_list ap)
Definition: fuse_log.h:52
fuse_log_level
fuse_log_level
Definition: fuse_log.h:28
fuse_set_log_func
void fuse_set_log_func(fuse_log_func_t func)
Definition: fuse_log.c:25