static void log_func(enum fuse_log_level level, const char *fmt, va_list ap)
{
    g_autofree char *localfmt = NULL;
    struct timespec ts;
    struct tm tm;
    char sec_fmt[sizeof "2020-12-07 18:17:54"];
    char zone_fmt[sizeof "+0100"];

    if (current_log_level < level) {
        return;
    }

    if (current_log_level == FUSE_LOG_DEBUG) {
        if (use_syslog) {
            /* no timestamp needed */
            localfmt = g_strdup_printf("[ID: %08ld] %s", syscall(__NR_gettid),
                                       fmt);
        } else {
            /* try formatting a broken-down timestamp */
            if (clock_gettime(CLOCK_REALTIME, &ts) != -1 &&
                localtime_r(&ts.tv_sec, &tm) != NULL &&
                strftime(sec_fmt, sizeof sec_fmt, "%Y-%m-%d %H:%M:%S",
                         &tm) != 0 &&
                strftime(zone_fmt, sizeof zone_fmt, "%z", &tm) != 0) {
                localfmt = g_strdup_printf("[%s.%02ld%s] [ID: %08ld] %s",
                                           sec_fmt,
                                           ts.tv_nsec / (10L * 1000 * 1000),
                                           zone_fmt, syscall(__NR_gettid),
                                           fmt);
            } else {
                /* fall back to a flat timestamp */
                localfmt = g_strdup_printf("[%" PRId64 "] [ID: %08ld] %s",
                                           get_clock(), syscall(__NR_gettid),
                                           fmt);
            }
        }
        fmt = localfmt;
    }

    if (use_syslog) {
        int priority = LOG_ERR;
        switch (level) {
        case FUSE_LOG_EMERG:
            priority = LOG_EMERG;
            break;
        case FUSE_LOG_ALERT:
            priority = LOG_ALERT;
            break;
        case FUSE_LOG_CRIT:
            priority = LOG_CRIT;
            break;
        case FUSE_LOG_ERR:
            priority = LOG_ERR;
            break;
        case FUSE_LOG_WARNING:
            priority = LOG_WARNING;
            break;
        case FUSE_LOG_NOTICE:
            priority = LOG_NOTICE;
            break;
        case FUSE_LOG_INFO:
            priority = LOG_INFO;
            break;
        case FUSE_LOG_DEBUG:
            priority = LOG_DEBUG;
            break;
        }
        vsyslog(priority, fmt, ap);
    } else {
        vfprintf(stderr, fmt, ap);
    }
}
static void log_func(enum fuse_log_level level, const char *fmt, va_list ap)
{
    g_autofree char *localfmt = NULL;
    struct timespec ts;
    struct tm tm;
    char sec_fmt[sizeof "2020-12-07 18:17:54"];
    char zone_fmt[sizeof "+0100"];

    if (current_log_level < level) {
        return;
    }

    if (current_log_level == FUSE_LOG_DEBUG) {
        if (use_syslog) {
             
            localfmt = g_strdup_printf("[ID: %08ld] %s", syscall(__NR_gettid),
                                       fmt);
        } else {
             
            if (clock_gettime(CLOCK_REALTIME, &ts) != -1 &&
                localtime_r(&ts.tv_sec, &tm) != NULL &&
                strftime(sec_fmt, sizeof sec_fmt, "%Y-%m-%d %H:%M:%S",
                         &tm) != 0 &&
                strftime(zone_fmt, sizeof zone_fmt, "%z", &tm) != 0) {
                localfmt = g_strdup_printf("[%s.%02ld%s] [ID: %08ld] %s",
                                           sec_fmt,
                                           ts.tv_nsec / (10L * 1000 * 1000),
                                           zone_fmt, syscall(__NR_gettid),
                                           fmt);
            } else {
                 
                localfmt = g_strdup_printf("[%" PRId64 "] [ID: %08ld] %s",
                                           get_clock(), syscall(__NR_gettid),
                                           fmt);
            }
        }
        fmt = localfmt;
    }

    if (use_syslog) {
        int priority = LOG_ERR;
        switch (level) {
        case FUSE_LOG_EMERG:
            priority = LOG_EMERG;
            break;
        case FUSE_LOG_ALERT:
            priority = LOG_ALERT;
            break;
        case FUSE_LOG_CRIT:
            priority = LOG_CRIT;
            break;
        case FUSE_LOG_ERR:
            priority = LOG_ERR;
            break;
        case FUSE_LOG_WARNING:
            priority = LOG_WARNING;
            break;
        case FUSE_LOG_NOTICE:
            priority = LOG_NOTICE;
            break;
        case FUSE_LOG_INFO:
            priority = LOG_INFO;
            break;
        case FUSE_LOG_DEBUG:
            priority = LOG_DEBUG;
            break;
        }
        vsyslog(priority, fmt, ap);
    } else {
        vfprintf(stderr, fmt, ap);
    }
}