VirtualBox

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

Last change on this file since 82968 was 82968, checked in by vboxsync, 5 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.9 KB
Line 
1/* $Id: VBoxDbgLog.h 82968 2020-02-04 10:35:17Z vboxsync $ */
2/** @file
3 * Logging helper
4 */
5
6/*
7 * Copyright (C) 2011-2020 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 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27#ifndef VBOX_INCLUDED_SRC_win_VBoxDbgLog_h
28#define VBOX_INCLUDED_SRC_win_VBoxDbgLog_h
29#ifndef RT_WITHOUT_PRAGMA_ONCE
30# pragma once
31#endif
32
33#ifndef VBOX_DBG_LOG_NAME
34# error VBOX_DBG_LOG_NAME should be defined!
35#endif
36
37/* Uncomment to show file/line info in the log */
38/*#define VBOX_DBG_LOG_SHOWLINEINFO*/
39
40#define VBOX_DBG_LOG_PREFIX_FMT VBOX_DBG_LOG_NAME"::"LOG_FN_FMT": "
41#define VBOX_DBG_LOG_PREFIX_PARMS __PRETTY_FUNCTION__
42
43#ifdef VBOX_DBG_LOG_SHOWLINEINFO
44# define VBOX_DBG_LOG_SUFFIX_FMT " (%s:%d)\n"
45# define VBOX_DBG_LOG_SUFFIX_PARMS ,__FILE__, __LINE__
46#else
47# define VBOX_DBG_LOG_SUFFIX_FMT "\n"
48# define VBOX_DBG_LOG_SUFFIX_PARMS
49#endif
50
51#ifdef DEBUG_misha
52# define BP_WARN() AssertFailed()
53#else
54# define BP_WARN() do { } while (0)
55#endif
56
57#define _LOGMSG_EXACT(_logger, _a) \
58 do \
59 { \
60 _logger(_a); \
61 } while (0)
62
63#define _LOGMSG(_logger, _a) \
64 do \
65 { \
66 _logger((VBOX_DBG_LOG_PREFIX_FMT, VBOX_DBG_LOG_PREFIX_PARMS)); \
67 _logger(_a); \
68 _logger((VBOX_DBG_LOG_SUFFIX_FMT VBOX_DBG_LOG_SUFFIX_PARMS)); \
69 } while (0)
70
71/* we can not print paged strings to RT logger, do it this way */
72#define _LOGMSG_STR(_logger, _a, _f) do {\
73 int _i = 0; \
74 _logger(("\"")); \
75 for (;(_a)[_i];++_i) { \
76 _logger(("%"_f, (_a)[_i])); \
77 }\
78 _logger(("\"\n")); \
79 } while (0)
80
81#define _LOGMSG_USTR(_logger, _a) do {\
82 int _i = 0; \
83 _logger(("\"")); \
84 for (;_i<(_a)->Length/2;++_i) { \
85 _logger(("%c", (_a)->Buffer[_i])); \
86 }\
87 _logger(("\"\n")); \
88 } while (0)
89
90#define WARN_NOBP(_a) \
91 do \
92 { \
93 Log((VBOX_DBG_LOG_PREFIX_FMT"WARNING! ", VBOX_DBG_LOG_PREFIX_PARMS)); \
94 Log(_a); \
95 Log((VBOX_DBG_LOG_SUFFIX_FMT VBOX_DBG_LOG_SUFFIX_PARMS)); \
96 } while (0)
97
98#define WARN(_a) \
99 do \
100 { \
101 WARN_NOBP(_a); \
102 BP_WARN(); \
103 } while (0)
104
105#define ASSERT_WARN(_a, _w) do {\
106 if(!(_a)) { \
107 WARN(_w); \
108 }\
109 } while (0)
110
111#define LOG(_a) _LOGMSG(Log, _a)
112#define LOGREL(_a) _LOGMSG(LogRel, _a)
113#define LOGF(_a) _LOGMSG(LogFlow, _a)
114#define LOGF_ENTER() LOGF(("ENTER"))
115#define LOGF_LEAVE() LOGF(("LEAVE"))
116#define LOG_EXACT(_a) _LOGMSG_EXACT(Log, _a)
117#define LOGREL_EXACT(_a) _LOGMSG_EXACT(LogRel, _a)
118/* we can not print paged strings to RT logger, do it this way */
119#define LOG_STRA(_a) do {\
120 _LOGMSG_STR(Log, _a, "c"); \
121 } while (0)
122#define LOG_STRW(_a) do {\
123 _LOGMSG_STR(Log, _a, "c"); \
124 } while (0)
125#define LOG_USTR(_a) do {\
126 _LOGMSG_USTR(Log, _a); \
127 } while (0)
128#define LOGREL_STRA(_a) do {\
129 _LOGMSG_STR(LogRel, _a, "c"); \
130 } while (0)
131#define LOGREL_STRW(_a) do {\
132 _LOGMSG_STR(LogRel, _a, "c"); \
133 } while (0)
134#define LOGREL_USTR(_a) do {\
135 _LOGMSG_USTR(LogRel, _a); \
136 } while (0)
137
138
139#endif /* !VBOX_INCLUDED_SRC_win_VBoxDbgLog_h */
140
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