1 /* 2 FUSE: Filesystem in Userspace 3 Copyright (C) 2019 Red Hat, Inc. 4 5 This program can be distributed under the terms of the GNU LGPLv2. 6 See the file COPYING.LIB. 7 */ 8 9 #ifndef FUSE_LOG_H_ 10 #define FUSE_LOG_H_ 11 12 /** @file 13 * 14 * This file defines the logging interface of FUSE 15 */ 16 17 #include <stdarg.h> 18 19 #ifdef __cplusplus 20 extern "C" { 21 #endif 22 23 /** 24 * Log severity level 25 * 26 * These levels correspond to syslog(2) log levels since they are widely used. 27 */ 28 enum fuse_log_level { 29 FUSE_LOG_EMERG, 30 FUSE_LOG_ALERT, 31 FUSE_LOG_CRIT, 32 FUSE_LOG_ERR, 33 FUSE_LOG_WARNING, 34 FUSE_LOG_NOTICE, 35 FUSE_LOG_INFO, 36 FUSE_LOG_DEBUG 37 }; 38 39 /** 40 * Log message handler function. 41 * 42 * This function must be thread-safe. It may be called from any libfuse 43 * function, including fuse_parse_cmdline() and other functions invoked before 44 * a FUSE filesystem is created. 45 * 46 * Install a custom log message handler function using fuse_set_log_func(). 47 * 48 * @param level log severity level 49 * @param fmt sprintf-style format string including newline 50 * @param ap format string arguments 51 */ 52 typedef void (*fuse_log_func_t)(enum fuse_log_level level, 53 const char *fmt, va_list ap); 54 55 /** 56 * Install a custom log handler function. 57 * 58 * Log messages are emitted by libfuse functions to report errors and debug 59 * information. Messages are printed to stderr by default but this can be 60 * overridden by installing a custom log message handler function. 61 * 62 * The log message handler function is global and affects all FUSE filesystems 63 * created within this process. 64 * 65 * @param func a custom log message handler function or NULL to revert to 66 * the default 67 */ 68 void fuse_set_log_func(fuse_log_func_t func); 69 70 /** 71 * Emit a log message 72 * 73 * @param level severity level (FUSE_LOG_ERR, FUSE_LOG_DEBUG, etc) 74 * @param fmt sprintf-style format string including newline 75 */ 76 void fuse_log(enum fuse_log_level level, const char *fmt, ...); 77 78 #ifdef __cplusplus 79 } 80 #endif 81 82 #endif /* FUSE_LOG_H_ */ 83