io_u: do nsec -> usec converison in one spot in account_io_completion()
[fio.git] / log.h
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 ({                                                      \
21         size_t __ret;                                   \
22         if ((buf) != NULL)                              \
23                 __ret = __log_buf(buf, format, ##args); \
24         else                                            \
25                 __ret = log_info(format, ##args);       \
26         __ret;                                          \
27 })
28
29 enum {
30         FIO_LOG_DEBUG   = 1,
31         FIO_LOG_INFO    = 2,
32         FIO_LOG_ERR     = 3,
33         FIO_LOG_NR      = 4,
34 };
35
36 extern const char *log_get_level(int level);
37
38 #endif