| 1 | /* log-for-trace.h: logging basics required by the trace.h generated |
| 2 | * by the log trace backend. |
| 3 | * |
| 4 | * This should not be included directly by any .c file: if you |
| 5 | * need to use the logging functions include "qemu/log.h". |
| 6 | * |
| 7 | * The purpose of splitting these parts out into their own header |
| 8 | * is to catch the easy mistake where a .c file includes trace.h |
| 9 | * but forgets to include qemu/log.h. Without this split, that |
| 10 | * would result in the .c file compiling fine when the default |
| 11 | * trace backend is in use but failing to compile with any other |
| 12 | * backend. |
| 13 | * |
| 14 | * This code is licensed under the GNU General Public License, |
| 15 | * version 2 or (at your option) any later version. |
| 16 | */ |
| 17 | |
| 18 | #ifndef QEMU_LOG_FOR_TRACE_H |
| 19 | #define QEMU_LOG_FOR_TRACE_H |
| 20 | |
| 21 | /* Private global variable, don't use */ |
| 22 | extern unsigned qemu_loglevel; |
| 23 | |
| 24 | #define LOG_TRACE (1u << 15) |
| 25 | |
| 26 | /* Returns true if a bit is set in the current loglevel mask */ |
| 27 | static inline bool qemu_loglevel_mask(int mask) |
| 28 | { |
| 29 | return (qemu_loglevel & mask) != 0; |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * qemu_log: report a log message |
| 34 | * @fmt: the format string for the message |
| 35 | * @...: the format string arguments |
| 36 | * |
| 37 | * This will emit a log message to the current output stream. |
| 38 | * |
| 39 | * The @fmt string should normally represent a complete line |
| 40 | * of text, and thus end with a newline character. |
| 41 | * |
| 42 | * While it is possible to incrementally output fragments of |
| 43 | * a complete line using qemu_log, this is inefficient and |
| 44 | * races with other threads. For outputting fragments it is |
| 45 | * strongly preferred to use the qemu_log_trylock() method |
| 46 | * combined with fprintf(). |
| 47 | */ |
| 48 | void G_GNUC_PRINTF(1, 2) qemu_log(const char *fmt, ...); |
| 49 | |
| 50 | #endif |