VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/win/VBoxDbgLog.h@ 42699

Last change on this file since 42699 was 38433, checked in by vboxsync, 13 years ago

eol-style

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.4 KB
Line 
1/* $Id: VBoxDbgLog.h 38433 2011-08-12 12:04:34Z vboxsync $ */
2
3/** @file
4 * Logging helper
5 */
6
7/*
8 * Copyright (C) 2011 Oracle Corporation
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License (GPL) as published by the Free Software
14 * Foundation, in version 2 as it comes in the "COPYING" file of the
15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17 */
18
19#ifndef ___VBoxDbgLog_h__
20#define ___VBoxDbgLog_h__
21
22#ifndef VBOX_DBG_LOG_NAME
23# error VBOX_DBG_LOG_NAME should be defined!
24#endif
25
26/* Uncomment to show file/line info in the log */
27/*#define VBOX_DBG_LOG_SHOWLINEINFO*/
28
29#define VBOX_DBG_LOG_PREFIX_FMT VBOX_DBG_LOG_NAME"::"LOG_FN_FMT": "
30#define VBOX_DBG_LOG_PREFIX_PARMS __PRETTY_FUNCTION__
31
32#ifdef VBOX_DBG_LOG_SHOWLINEINFO
33# define VBOX_DBG_LOG_SUFFIX_FMT " (%s:%d)\n"
34# define VBOX_DBG_LOG_SUFFIX_PARMS ,__FILE__, __LINE__
35#else
36# define VBOX_DBG_LOG_SUFFIX_FMT "\n"
37# define VBOX_DBG_LOG_SUFFIX_PARMS
38#endif
39
40#ifdef DEBUG_misha
41# define BP_WARN() AssertFailed()
42#else
43# define BP_WARN() do {} while(0)
44#endif
45
46#define _LOGMSG_EXACT(_logger, _a) \
47 do \
48 { \
49 _logger(_a); \
50 } while (0)
51
52#define _LOGMSG(_logger, _a) \
53 do \
54 { \
55 _logger((VBOX_DBG_LOG_PREFIX_FMT, VBOX_DBG_LOG_PREFIX_PARMS)); \
56 _logger(_a); \
57 _logger((VBOX_DBG_LOG_SUFFIX_FMT VBOX_DBG_LOG_SUFFIX_PARMS)); \
58 } while (0)
59
60/* we can not print paged strings to RT logger, do it this way */
61#define _LOGMSG_STR(_logger, _a, _f) do {\
62 int _i = 0; \
63 _logger(("\"")); \
64 for (;(_a)[_i];++_i) { \
65 _logger(("%"_f, (_a)[_i])); \
66 }\
67 _logger(("\"\n")); \
68 } while (0)
69
70#define _LOGMSG_USTR(_logger, _a) do {\
71 int _i = 0; \
72 _logger(("\"")); \
73 for (;_i<(_a)->Length/2;++_i) { \
74 _logger(("%c", (_a)->Buffer[_i])); \
75 }\
76 _logger(("\"\n")); \
77 } while (0)
78
79#define WARN_NOBP(_a) \
80 do \
81 { \
82 Log((VBOX_DBG_LOG_PREFIX_FMT"WARNING! ", VBOX_DBG_LOG_PREFIX_PARMS)); \
83 Log(_a); \
84 Log((VBOX_DBG_LOG_SUFFIX_FMT VBOX_DBG_LOG_SUFFIX_PARMS)); \
85 } while (0)
86
87#define WARN(_a) \
88 do \
89 { \
90 WARN_NOBP(_a); \
91 BP_WARN(); \
92 } while (0)
93
94#define ASSERT_WARN(_a, _w) do {\
95 if(!(_a)) { \
96 WARN(_w); \
97 }\
98 } while (0)
99
100#define LOG(_a) _LOGMSG(Log, _a)
101#define LOGREL(_a) _LOGMSG(LogRel, _a)
102#define LOGF(_a) _LOGMSG(LogFlow, _a)
103#define LOGF_ENTER() LOGF(("ENTER"))
104#define LOGF_LEAVE() LOGF(("LEAVE"))
105#define LOG_EXACT(_a) _LOGMSG_EXACT(Log, _a)
106#define LOGREL_EXACT(_a) _LOGMSG_EXACT(LogRel, _a)
107/* we can not print paged strings to RT logger, do it this way */
108#define LOG_STRA(_a) do {\
109 _LOGMSG_STR(Log, _a, "c"); \
110 } while (0)
111#define LOG_STRW(_a) do {\
112 _LOGMSG_STR(Log, _a, "c"); \
113 } while (0)
114#define LOG_USTR(_a) do {\
115 _LOGMSG_USTR(Log, _a); \
116 } while (0)
117#define LOGREL_STRA(_a) do {\
118 _LOGMSG_STR(LogRel, _a, "c"); \
119 } while (0)
120#define LOGREL_STRW(_a) do {\
121 _LOGMSG_STR(LogRel, _a, "c"); \
122 } while (0)
123#define LOGREL_USTR(_a) do {\
124 _LOGMSG_USTR(LogRel, _a); \
125 } while (0)
126
127
128#endif /*___VBoxDbgLog_h__*/
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