VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Video/common/VBoxVideoLog.h

Last change on this file was 98103, checked in by vboxsync, 16 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.3 KB
Line 
1/* $Id: VBoxVideoLog.h 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * VBox Video drivers, logging helper
4 */
5
6/*
7 * Copyright (C) 2011-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#ifndef GA_INCLUDED_SRC_WINNT_Graphics_Video_common_VBoxVideoLog_h
29#define GA_INCLUDED_SRC_WINNT_Graphics_Video_common_VBoxVideoLog_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34#ifndef VBOX_VIDEO_LOG_NAME
35# error VBOX_VIDEO_LOG_NAME should be defined!
36#endif
37
38#ifndef VBOX_VIDEO_LOG_LOGGER
39# define VBOX_VIDEO_LOG_LOGGER Log
40#endif
41
42#ifndef VBOX_VIDEO_LOGREL_LOGGER
43# define VBOX_VIDEO_LOGREL_LOGGER LogRel
44#endif
45
46#ifndef VBOX_VIDEO_LOGFLOW_LOGGER
47# define VBOX_VIDEO_LOGFLOW_LOGGER LogFlow
48#endif
49
50#ifndef VBOX_VIDEO_LOG_FN_FMT
51# define VBOX_VIDEO_LOG_FN_FMT LOG_FN_FMT
52#endif
53
54#ifndef VBOX_VIDEO_LOG_FORMATTER
55# define VBOX_VIDEO_LOG_FORMATTER(_logger, _severity, _a) \
56 do \
57 { \
58 _logger((VBOX_VIDEO_LOG_PREFIX_FMT _severity, VBOX_VIDEO_LOG_PREFIX_PARMS)); \
59 _logger(_a); \
60 _logger((VBOX_VIDEO_LOG_SUFFIX_FMT VBOX_VIDEO_LOG_SUFFIX_PARMS)); \
61 } while (0)
62#endif
63
64/* Uncomment to show file/line info in the log */
65/*#define VBOX_VIDEO_LOG_SHOWLINEINFO*/
66
67#define VBOX_VIDEO_LOG_PREFIX_FMT VBOX_VIDEO_LOG_NAME"::"VBOX_VIDEO_LOG_FN_FMT": "
68#define VBOX_VIDEO_LOG_PREFIX_PARMS __FUNCTION__
69
70#ifdef VBOX_VIDEO_LOG_SHOWLINEINFO
71# define VBOX_VIDEO_LOG_SUFFIX_FMT " (%s:%d)\n"
72# define VBOX_VIDEO_LOG_SUFFIX_PARMS ,__FILE__, __LINE__
73#else
74# define VBOX_VIDEO_LOG_SUFFIX_FMT "\n"
75# define VBOX_VIDEO_LOG_SUFFIX_PARMS
76#endif
77
78#ifdef DEBUG_sunlover
79# define BP_WARN() AssertFailed()
80#else
81# define BP_WARN() do {} while(0)
82#endif
83
84#define _LOGMSG_EXACT(_logger, _a) \
85 do \
86 { \
87 _logger(_a); \
88 } while (0)
89
90#define _LOGMSG(_logger, _severity, _a) \
91 do \
92 { \
93 VBOX_VIDEO_LOG_FORMATTER(_logger, _severity, _a); \
94 } while (0)
95
96/* we can not print paged strings to RT logger, do it this way */
97#define _LOGMSG_STR(_logger, _a, _f) do {\
98 int _i = 0; \
99 for (;(_a)[_i];++_i) { \
100 _logger(("%"_f, (_a)[_i])); \
101 }\
102 _logger(("\n")); \
103 } while (0)
104
105#ifdef VBOX_WDDM_MINIPORT
106# define _WARN_LOGGER VBOX_VIDEO_LOGREL_LOGGER
107#else
108# define _WARN_LOGGER VBOX_VIDEO_LOG_LOGGER
109#endif
110
111#define WARN_NOBP(_a) _LOGMSG(_WARN_LOGGER, "WARNING! :", _a)
112#define WARN(_a) \
113 do \
114 { \
115 WARN_NOBP(_a); \
116 BP_WARN(); \
117 } while (0)
118
119#define ASSERT_WARN(_a, _w) do {\
120 if(!(_a)) { \
121 WARN(_w); \
122 }\
123 } while (0)
124
125#define STOP_FATAL() do { \
126 AssertReleaseFailed(); \
127 } while (0)
128#define ERR(_a) do { \
129 _LOGMSG(VBOX_VIDEO_LOGREL_LOGGER, "FATAL! :", _a); \
130 STOP_FATAL(); \
131 } while (0)
132
133#define _DBGOP_N_TIMES(_count, _op) do { \
134 static int fDoWarnCount = (_count); \
135 if (fDoWarnCount) { \
136 --fDoWarnCount; \
137 _op; \
138 } \
139 } while (0)
140
141#define WARN_ONCE(_a) do { \
142 _DBGOP_N_TIMES(1, WARN(_a)); \
143 } while (0)
144
145
146#define LOG(_a) _LOGMSG(VBOX_VIDEO_LOG_LOGGER, "", _a)
147#define LOGREL(_a) _LOGMSG(VBOX_VIDEO_LOGREL_LOGGER, "", _a)
148#define LOGF(_a) _LOGMSG(VBOX_VIDEO_LOGFLOW_LOGGER, "", _a)
149#define LOGF_ENTER() LOGF(("ENTER"))
150#define LOGF_LEAVE() LOGF(("LEAVE"))
151#define LOG_EXACT(_a) _LOGMSG_EXACT(VBOX_VIDEO_LOG_LOGGER, _a)
152#define LOGREL_EXACT(_a) _LOGMSG_EXACT(VBOX_VIDEO_LOGREL_LOGGER, _a)
153#define LOGF_EXACT(_a) _LOGMSG_EXACT(VBOX_VIDEO_LOGFLOW_LOGGER, _a)
154/* we can not print paged strings to RT logger, do it this way */
155#define LOG_STRA(_a) do {\
156 _LOGMSG_STR(VBOX_VIDEO_LOG_LOGGER, _a, "c"); \
157 } while (0)
158#define LOG_STRW(_a) do {\
159 _LOGMSG_STR(VBOX_VIDEO_LOG_LOGGER, _a, "c"); \
160 } while (0)
161#define LOGREL_STRA(_a) do {\
162 _LOGMSG_STR(VBOX_VIDEO_LOGREL_LOGGER, _a, "c"); \
163 } while (0)
164#define LOGREL_STRW(_a) do {\
165 _LOGMSG_STR(VBOX_VIDEO_LOGREL_LOGGER, _a, "c"); \
166 } while (0)
167
168
169#endif /* !GA_INCLUDED_SRC_WINNT_Graphics_Video_common_VBoxVideoLog_h */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use