VirtualBox

source: vbox/trunk/src/recompiler/qemu-log.h@ 63969

Last change on this file since 63969 was 55980, checked in by vboxsync, 9 years ago

iprt/log.h,++: Added extended logger instance getters that also checks whether the given logger and group-flags are enabled, making the LogRel* checks more efficient in avoid uncessary RTLogLoggerEx parameter building and calls. Ditto for debug logging. The LOG_INSTANCE and LOG_REL_INSTANCE tricks are gone for now.

  • Property svn:eol-style set to native
File size: 3.0 KB
Line 
1#ifndef QEMU_LOG_H
2#define QEMU_LOG_H
3
4/* The deprecated global variables: */
5extern FILE *logfile;
6extern int loglevel;
7
8
9/*
10 * The new API:
11 *
12 */
13
14/* Log settings checking macros: */
15
16/* Returns true if qemu_log() will really write somewhere
17 */
18#ifndef VBOX
19#define qemu_log_enabled() (logfile != NULL)
20#else
21# define qemu_log_enabled() LogIsEnabled()
22#endif
23
24/* Returns true if a bit is set in the current loglevel mask
25 */
26#define qemu_loglevel_mask(b) ((loglevel & (b)) != 0)
27
28
29/* Logging functions: */
30
31/* main logging function
32 */
33#ifndef VBOX
34#define qemu_log(...) do { \
35 if (logfile) \
36 fprintf(logfile, ## __VA_ARGS__); \
37 } while (0)
38#else
39# define qemu_log(...) Log((__VA_ARGS__))
40#endif
41
42/* vfprintf-like logging function
43 */
44#ifndef VBOX
45#define qemu_log_vprintf(fmt, va) do { \
46 if (logfile) \
47 vfprintf(logfile, fmt, va); \
48 } while (0)
49#else
50# define qemu_log_vprintf(fmt, va) do { \
51 if (LogIsEnabled()) \
52 RTLogLoggerExV(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, fmt, va); \
53 } while (0)
54#endif
55
56/* log only if a bit is set on the current loglevel mask
57 */
58#ifndef VBOX
59#define qemu_log_mask(b, ...) do { \
60 if (loglevel & (b)) \
61 fprintf(logfile, ## __VA_ARGS__); \
62 } while (0)
63#else
64# define qemu_log_mask(b, ...) do { \
65 if (loglevel & (b)) \
66 Log((__VA_ARGS__)); \
67 } while (0)
68#endif
69
70
71
72
73/* Special cases: */
74
75/* cpu_dump_state() logging functions: */
76#ifndef VBOX
77#define log_cpu_state(env, f) cpu_dump_state((env), logfile, fprintf, (f));
78#else
79#define log_cpu_state(env, f) cpu_dump_state((env), NULL, NULL, (f));
80#endif
81#define log_cpu_state_mask(b, env, f) do { \
82 if (loglevel & (b)) log_cpu_state((env), (f)); \
83 } while (0)
84
85/* disas() and target_disas() to logfile: */
86#define log_target_disas(start, len, flags) \
87 target_disas(logfile, (start), (len), (flags))
88#define log_disas(start, len) \
89 disas(logfile, (start), (len))
90
91/* page_dump() output to the log file: */
92#define log_page_dump() page_dump(logfile)
93
94
95
96/* Maintenance: */
97
98/* fflush() the log file */
99#ifndef VBOX
100#define qemu_log_flush() fflush(logfile)
101#else
102# define qemu_log_flush() RTLogFlush(NULL)
103#endif
104
105/* Close the log file */
106#ifndef VBOX
107#define qemu_log_close() do { \
108 fclose(logfile); \
109 logfile = NULL; \
110 } while (0)
111#else
112# define qemu_log_close() do { } while (0)
113#endif
114
115/* Set up a new log file */
116#ifndef VBOX
117#define qemu_log_set_file(f) do { \
118 logfile = (f); \
119 } while (0)
120#else
121# define qemu_log_set_file(f) do { } while (0)
122#endif
123
124/* Set up a new log file, only if none is set */
125#ifndef VBOX
126#define qemu_log_try_set_file(f) do { \
127 if (!logfile) \
128 logfile = (f); \
129 } while (0)
130#else
131#define qemu_log_try_set_file(f) do { } while (0)
132#endif
133
134
135#endif
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette