VirtualBox

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

Last change on this file since 38262 was 38262, checked in by vboxsync, 14 years ago

usb/win: better logging & cleanup

File size: 4.1 KB
Line 
1/* $Id$ */
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 for (;(_a)[_i];++_i) { \
64 _logger(("%"_f, (_a)[_i])); \
65 }\
66 _logger(("\n")); \
67 } while (0)
68
69#define WARN_NOBP(_a) \
70 do \
71 { \
72 Log((VBOX_DBG_LOG_PREFIX_FMT"WARNING! ", VBOX_DBG_LOG_PREFIX_PARMS)); \
73 Log(_a); \
74 Log((VBOX_DBG_LOG_SUFFIX_FMT VBOX_DBG_LOG_SUFFIX_PARMS)); \
75 } while (0)
76
77#define WARN(_a) \
78 do \
79 { \
80 WARN_NOBP(_a); \
81 BP_WARN(); \
82 } while (0)
83
84#define ASSERT_WARN(_a, _w) do {\
85 if(!(_a)) { \
86 WARN(_w); \
87 }\
88 } while (0)
89
90#define LOG(_a) _LOGMSG(Log, _a)
91#define LOGREL(_a) _LOGMSG(LogRel, _a)
92#define LOGF(_a) _LOGMSG(LogFlow, _a)
93#define LOGF_ENTER() LOGF(("ENTER"))
94#define LOGF_LEAVE() LOGF(("LEAVE"))
95#define LOG_EXACT(_a) _LOGMSG_EXACT(Log, _a)
96#define LOGREL_EXACT(_a) _LOGMSG_EXACT(LogRel, _a)
97/* we can not print paged strings to RT logger, do it this way */
98#define LOG_STRA(_a) do {\
99 _LOGMSG_STR(Log, _a, "c"); \
100 } while (0)
101#define LOG_STRW(_a) do {\
102 _LOGMSG_STR(Log, _a, "c"); \
103 } while (0)
104#define LOGREL_STRA(_a) do {\
105 _LOGMSG_STR(LogRel, _a, "c"); \
106 } while (0)
107#define LOGREL_STRW(_a) do {\
108 _LOGMSG_STR(LogRel, _a, "c"); \
109 } while (0)
110
111
112#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