VirtualBox

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

Last change on this file since 67981 was 62715, checked in by vboxsync, 8 years ago

HostDrivers: warnings

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

© 2023 Oracle
ContactPrivacy policyTerms of Use