VirtualBox

source: vbox/trunk/src/VBox/Main/include/Logging.h@ 8217

Last change on this file since 8217 was 8180, checked in by vboxsync, 17 years ago

Main: Important warning about MyLog*() usage.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.3 KB
Line 
1/** @file
2 *
3 * VirtualBox COM: logging macros and function definitions
4 */
5
6/*
7 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22#ifndef ____H_LOGGING
23#define ____H_LOGGING
24
25/** @def LOG_GROUP_MAIN_OVERRIDE
26 * Define this macro to point to the desired log group before including
27 * the |Logging.h| header if you want to use a group other than LOG_GROUP_MAIN
28 * for logging from within Main source files.
29 *
30 * @example #define LOG_GROUP_MAIN_OVERRIDE LOG_GROUP_HGCM
31 */
32
33/*
34 * We might be including the VBox logging subsystem before
35 * including this header file, so reset the logging group.
36 */
37#ifdef LOG_GROUP
38# undef LOG_GROUP
39#endif
40#ifdef LOG_GROUP_MAIN_OVERRIDE
41# define LOG_GROUP LOG_GROUP_MAIN_OVERRIDE
42#else
43# define LOG_GROUP LOG_GROUP_MAIN
44#endif
45
46/* Ensure log macros are enabled if release logging is requested */
47#if defined (VBOX_MAIN_RELEASE_LOG) && !defined (DEBUG)
48# ifndef LOG_ENABLED
49# define LOG_ENABLED
50# endif
51#endif
52
53#include <VBox/log.h>
54#include <iprt/assert.h>
55
56/** @deprecated Please use LogFlowThisFunc instead! */
57#define LogFlowMember(m) \
58 do { LogFlow (("{%p} ", this)); LogFlow (m); } while (0)
59
60/** @def MyLogIt
61 * Copy of LogIt that works even when logging is completely disabled (e.g. in
62 * release builds) and doesn't interefere with the default release logger
63 * instance (which is already in use by the VM process).
64 *
65 * @warning Logging using MyLog* is intended only as a temporary mean to debug
66 * release builds (e.g. in case if the error is not reproducible with
67 * the debug builds)! Any MyLog* usage must be removed from the sources
68 * after the error has been fixed.
69 */
70#define MyLogIt(pvInst, fFlags, iGroup, fmtargs) \
71 do \
72 { \
73 register PRTLOGGER LogIt_pLogger = (PRTLOGGER)(pvInst) ? (PRTLOGGER)(pvInst) : RTLogDefaultInstance(); \
74 if (LogIt_pLogger) \
75 { \
76 register unsigned LogIt_fFlags = LogIt_pLogger->afGroups[(unsigned)(iGroup) < LogIt_pLogger->cGroups ? (unsigned)(iGroup) : 0]; \
77 if ((LogIt_fFlags & ((fFlags) | RTLOGGRPFLAGS_ENABLED)) == ((fFlags) | RTLOGGRPFLAGS_ENABLED)) \
78 LogIt_pLogger->pfnLogger fmtargs; \
79 } \
80 } while (0)
81
82/** @def MyLog
83 * Equivalent to LogFlow but uses MyLogIt instead of LogIt.
84 *
85 * @warning Logging using MyLog* is intended only as a temporary mean to debug
86 * release builds (e.g. in case if the error is not reproducible with
87 * the debug builds)! Any MyLog* usage must be removed from the sources
88 * after the error has been fixed.
89 */
90#define MyLog(a) MyLogIt(LOG_INSTANCE, RTLOGGRPFLAGS_FLOW, LOG_GROUP, a)
91
92#endif // ____H_LOGGING
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