qemu/include/qemu/log-for-trace.h
Peter Maydell be0aa7ac89 log-for-trace.h: Split out parts of log.h used by trace.h
A persistent build problem we see is where a source file
accidentally omits the #include of log.h. This slips through
local developer testing because if you configure with the
default (log) trace backend trace.h will pull in log.h for you.
Compilation fails only if some other backend is selected.

To make this error cause a compile failure regardless of
the configured trace backend, split out the parts of log.h
that trace.h requires into a new log-for-trace.h header.
Since almost all manual uses of the log.h functions will
use constants or functions which aren't in log-for-trace.h,
this will let us catch missing #include "qemu/log.h" more
consistently.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20180213140029.8308-1-peter.maydell@linaro.org
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2018-03-12 11:10:20 +00:00

36 lines
1.1 KiB
C

/* log-for-trace.h: logging basics required by the trace.h generated
* by the log trace backend.
*
* This should not be included directly by any .c file: if you
* need to use the logging functions include "qemu/log.h".
*
* The purpose of splitting these parts out into their own header
* is to catch the easy mistake where a .c file includes trace.h
* but forgets to include qemu/log.h. Without this split, that
* would result in the .c file compiling fine when the default
* trace backend is in use but failing to compile with any other
* backend.
*
* This code is licensed under the GNU General Public License,
* version 2 or (at your option) any later version.
*/
#ifndef QEMU_LOG_FOR_TRACE_H
#define QEMU_LOG_FOR_TRACE_H
/* Private global variable, don't use */
extern int qemu_loglevel;
#define LOG_TRACE (1 << 15)
/* Returns true if a bit is set in the current loglevel mask */
static inline bool qemu_loglevel_mask(int mask)
{
return (qemu_loglevel & mask) != 0;
}
/* main logging function */
int GCC_FMT_ATTR(1, 2) qemu_log(const char *fmt, ...);
#endif