1 #ifndef FIO_LOG_H 2 #define FIO_LOG_H 3 4 #include <stdio.h> 5 #include <stdarg.h> 6 7 #include "lib/output_buffer.h" 8 9 extern FILE *f_out; 10 extern FILE *f_err; 11 12 extern size_t log_err(const char *format, ...) __attribute__ ((__format__ (__printf__, 1, 2))); 13 extern size_t log_info(const char *format, ...) __attribute__ ((__format__ (__printf__, 1, 2))); 14 extern size_t __log_buf(struct buf_output *, const char *format, ...) __attribute__ ((__format__ (__printf__, 2, 3))); 15 extern size_t log_valist(const char *str, va_list); 16 extern size_t log_info_buf(const char *buf, size_t len); 17 extern int log_info_flush(void); 18 19 #define log_buf(buf, format, args...) \ 20 do { \ 21 if ((buf) != NULL) \ 22 __log_buf(buf, format, ##args); \ 23 else \ 24 log_info(format, ##args); \ 25 } while (0) 26 27 enum { 28 FIO_LOG_DEBUG = 1, 29 FIO_LOG_INFO = 2, 30 FIO_LOG_ERR = 3, 31 FIO_LOG_NR = 4, 32 }; 33 34 extern const char *log_get_level(int level); 35 36 #endif 37