summaryrefslogtreecommitdiffstats
path: root/tools/virtiofsd/fuse_log.c
blob: 745d88cd2a496fd7554fa21b3833b32ea6f7012d (plain) (blame)
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
/*
 * FUSE: Filesystem in Userspace
 * Copyright (C) 2019  Red Hat, Inc.
 *
 * Logging API.
 *
 * This program can be distributed under the terms of the GNU LGPLv2.
 * See the file COPYING.LIB
 */

#include "qemu/osdep.h"
#include "fuse_log.h"


static void default_log_func(__attribute__((unused)) enum fuse_log_level level,
                             const char *fmt, va_list ap)
{
    vfprintf(stderr, fmt, ap);
}

static fuse_log_func_t log_func = default_log_func;

void fuse_set_log_func(fuse_log_func_t func)
{
    if (!func) {
        func = default_log_func;
    }

    log_func = func;
}

void fuse_log(enum fuse_log_level level, const char *fmt, ...)
{
    va_list ap;

    va_start(ap, fmt);
    log_func(level, fmt, ap);
    va_end(ap);
}