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 | #if defined(RT_ARCH_AMD64) || defined(LOG_USE_C99)
|
---|
71 | # define _MyLogRemoveParentheseis(...) __VA_ARGS__
|
---|
72 | # define _MyLogIt(pvInst, fFlags, iGroup, ...) RTLogLoggerEx((PRTLOGGER)pvInst, fFlags, iGroup, __VA_ARGS__)
|
---|
73 | # define MyLogIt(pvInst, fFlags, iGroup, fmtargs) _MyLogIt(pvInst, fFlags, iGroup, _MyLogRemoveParentheseis fmtargs)
|
---|
74 | #else
|
---|
75 | # define MyLogIt(pvInst, fFlags, iGroup, fmtargs) \
|
---|
76 | do \
|
---|
77 | { \
|
---|
78 | register PRTLOGGER LogIt_pLogger = (PRTLOGGER)(pvInst) ? (PRTLOGGER)(pvInst) : RTLogDefaultInstance(); \
|
---|
79 | if (LogIt_pLogger) \
|
---|
80 | { \
|
---|
81 | register unsigned LogIt_fFlags = LogIt_pLogger->afGroups[(unsigned)(iGroup) < LogIt_pLogger->cGroups ? (unsigned)(iGroup) : 0]; \
|
---|
82 | if ((LogIt_fFlags & ((fFlags) | RTLOGGRPFLAGS_ENABLED)) == ((fFlags) | RTLOGGRPFLAGS_ENABLED)) \
|
---|
83 | LogIt_pLogger->pfnLogger fmtargs; \
|
---|
84 | } \
|
---|
85 | } while (0)
|
---|
86 | #endif
|
---|
87 |
|
---|
88 | /** @def MyLog
|
---|
89 | * Equivalent to LogFlow but uses MyLogIt instead of LogIt.
|
---|
90 | *
|
---|
91 | * @warning Logging using MyLog* is intended only as a temporary mean to debug
|
---|
92 | * release builds (e.g. in case if the error is not reproducible with
|
---|
93 | * the debug builds)! Any MyLog* usage must be removed from the sources
|
---|
94 | * after the error has been fixed.
|
---|
95 | */
|
---|
96 | #define MyLog(a) MyLogIt(LOG_INSTANCE, RTLOGGRPFLAGS_FLOW, LOG_GROUP, a)
|
---|
97 |
|
---|
98 | #endif // ____H_LOGGING
|
---|