16881f68fSopenharmony_ci/* 26881f68fSopenharmony_ci FUSE: Filesystem in Userspace 36881f68fSopenharmony_ci Copyright (C) 2019 Red Hat, Inc. 46881f68fSopenharmony_ci 56881f68fSopenharmony_ci This program can be distributed under the terms of the GNU LGPLv2. 66881f68fSopenharmony_ci See the file COPYING.LIB. 76881f68fSopenharmony_ci*/ 86881f68fSopenharmony_ci 96881f68fSopenharmony_ci#ifndef FUSE_LOG_H_ 106881f68fSopenharmony_ci#define FUSE_LOG_H_ 116881f68fSopenharmony_ci 126881f68fSopenharmony_ci/** @file 136881f68fSopenharmony_ci * 146881f68fSopenharmony_ci * This file defines the logging interface of FUSE 156881f68fSopenharmony_ci */ 166881f68fSopenharmony_ci 176881f68fSopenharmony_ci#include <stdarg.h> 186881f68fSopenharmony_ci 196881f68fSopenharmony_ci#ifdef __cplusplus 206881f68fSopenharmony_ciextern "C" { 216881f68fSopenharmony_ci#endif 226881f68fSopenharmony_ci 236881f68fSopenharmony_ci/** 246881f68fSopenharmony_ci * Log severity level 256881f68fSopenharmony_ci * 266881f68fSopenharmony_ci * These levels correspond to syslog(2) log levels since they are widely used. 276881f68fSopenharmony_ci */ 286881f68fSopenharmony_cienum fuse_log_level { 296881f68fSopenharmony_ci FUSE_LOG_EMERG, 306881f68fSopenharmony_ci FUSE_LOG_ALERT, 316881f68fSopenharmony_ci FUSE_LOG_CRIT, 326881f68fSopenharmony_ci FUSE_LOG_ERR, 336881f68fSopenharmony_ci FUSE_LOG_WARNING, 346881f68fSopenharmony_ci FUSE_LOG_NOTICE, 356881f68fSopenharmony_ci FUSE_LOG_INFO, 366881f68fSopenharmony_ci FUSE_LOG_DEBUG 376881f68fSopenharmony_ci}; 386881f68fSopenharmony_ci 396881f68fSopenharmony_ci/** 406881f68fSopenharmony_ci * Log message handler function. 416881f68fSopenharmony_ci * 426881f68fSopenharmony_ci * This function must be thread-safe. It may be called from any libfuse 436881f68fSopenharmony_ci * function, including fuse_parse_cmdline() and other functions invoked before 446881f68fSopenharmony_ci * a FUSE filesystem is created. 456881f68fSopenharmony_ci * 466881f68fSopenharmony_ci * Install a custom log message handler function using fuse_set_log_func(). 476881f68fSopenharmony_ci * 486881f68fSopenharmony_ci * @param level log severity level 496881f68fSopenharmony_ci * @param fmt sprintf-style format string including newline 506881f68fSopenharmony_ci * @param ap format string arguments 516881f68fSopenharmony_ci */ 526881f68fSopenharmony_citypedef void (*fuse_log_func_t)(enum fuse_log_level level, 536881f68fSopenharmony_ci const char *fmt, va_list ap); 546881f68fSopenharmony_ci 556881f68fSopenharmony_ci/** 566881f68fSopenharmony_ci * Install a custom log handler function. 576881f68fSopenharmony_ci * 586881f68fSopenharmony_ci * Log messages are emitted by libfuse functions to report errors and debug 596881f68fSopenharmony_ci * information. Messages are printed to stderr by default but this can be 606881f68fSopenharmony_ci * overridden by installing a custom log message handler function. 616881f68fSopenharmony_ci * 626881f68fSopenharmony_ci * The log message handler function is global and affects all FUSE filesystems 636881f68fSopenharmony_ci * created within this process. 646881f68fSopenharmony_ci * 656881f68fSopenharmony_ci * @param func a custom log message handler function or NULL to revert to 666881f68fSopenharmony_ci * the default 676881f68fSopenharmony_ci */ 686881f68fSopenharmony_civoid fuse_set_log_func(fuse_log_func_t func); 696881f68fSopenharmony_ci 706881f68fSopenharmony_ci/** 716881f68fSopenharmony_ci * Emit a log message 726881f68fSopenharmony_ci * 736881f68fSopenharmony_ci * @param level severity level (FUSE_LOG_ERR, FUSE_LOG_DEBUG, etc) 746881f68fSopenharmony_ci * @param fmt sprintf-style format string including newline 756881f68fSopenharmony_ci */ 766881f68fSopenharmony_civoid fuse_log(enum fuse_log_level level, const char *fmt, ...); 776881f68fSopenharmony_ci 786881f68fSopenharmony_ci#ifdef __cplusplus 796881f68fSopenharmony_ci} 806881f68fSopenharmony_ci#endif 816881f68fSopenharmony_ci 826881f68fSopenharmony_ci#endif /* FUSE_LOG_H_ */ 83