Logging.h revision 2ec3f96ee9cdda91a08a0e1028099575e802d387
/* $Id$ */
/** @file
*
* VirtualBox COM: logging macros and function definitions
*/
/*
* Copyright (C) 2006-2010 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#ifndef ____H_LOGGING
#define ____H_LOGGING
/** @def LOG_GROUP_MAIN_OVERRIDE
* Define this macro to point to the desired log group before including
* the |Logging.h| header if you want to use a group other than LOG_GROUP_MAIN
* for logging from within Main source files.
*
* @example #define LOG_GROUP_MAIN_OVERRIDE LOG_GROUP_HGCM
*/
/*
* We might be including the VBox logging subsystem before
* including this header file, so reset the logging group.
*/
#ifdef LOG_GROUP
#endif
#ifdef LOG_GROUP_MAIN_OVERRIDE
# define LOG_GROUP LOG_GROUP_MAIN_OVERRIDE
#else
# define LOG_GROUP LOG_GROUP_MAIN
#endif
/* Ensure log macros are enabled if release logging is requested */
#if defined (VBOX_MAIN_RELEASE_LOG) && !defined (DEBUG)
# ifndef LOG_ENABLED
# define LOG_ENABLED
# endif
#endif
/** @def MyLogIt
* Copy of LogIt that works even when logging is completely disabled (e.g. in
* release builds) and doesn't interefere with the default release logger
* instance (which is already in use by the VM process).
*
* @warning Logging using MyLog* is intended only as a temporary mean to debug
* release builds (e.g. in case if the error is not reproducible with
* the debug builds)! Any MyLog* usage must be removed from the sources
* after the error has been fixed.
*/
#if defined(RT_ARCH_AMD64) || defined(LOG_USE_C99)
# define _MyLogRemoveParentheseis(...) __VA_ARGS__
# define _MyLogIt(pvInst, fFlags, iGroup, ...) RTLogLoggerEx((PRTLOGGER)pvInst, fFlags, iGroup, __VA_ARGS__)
# define MyLogIt(pvInst, fFlags, iGroup, fmtargs) _MyLogIt(pvInst, fFlags, iGroup, _MyLogRemoveParentheseis fmtargs)
#else
do \
{ \
register PRTLOGGER LogIt_pLogger = (PRTLOGGER)(pvInst) ? (PRTLOGGER)(pvInst) : RTLogDefaultInstance(); \
if (LogIt_pLogger) \
{ \
register unsigned LogIt_fFlags = LogIt_pLogger->afGroups[(unsigned)(iGroup) < LogIt_pLogger->cGroups ? (unsigned)(iGroup) : 0]; \
} \
} while (0)
#endif
/** @def MyLog
* Equivalent to LogFlow but uses MyLogIt instead of LogIt.
*
* @warning Logging using MyLog* is intended only as a temporary mean to debug
* release builds (e.g. in case if the error is not reproducible with
* the debug builds)! Any MyLog* usage must be removed from the sources
* after the error has been fixed.
*/
#include <iprt/critsect.h>
void MLDMemInit (const char *pszPrefix);
void MLDMemUninit (void);
void MLDMemDump (void);
#define MLDMemAlloc(__cb) MLDMemAllocDbg (__cb, false /* fTmp */, false /* fZero */, __FILE__, __LINE__)
#define MLDMemAllocZ(__cb) MLDMemAllocDbg (__cb, false /* fTmp */, true /* fZero */, __FILE__, __LINE__)
#define MLDMemTmpAlloc(__cb) MLDMemAllocDbg (__cb, true /* fTmp */, false /* fZero */, __FILE__, __LINE__)
#define MLDMemTmpAllocZ(__cb) MLDMemAllocDbg (__cb, true /* fTmp */, true /* fZero */, __FILE__, __LINE__)
#define RTMemAlloc MLDMemAlloc
#define RTMemAllocZ MLDMemAllocZ
#define RTMemTmpAlloc MLDMemTmpAlloc
#define RTMemTmpAllocZ MLDMemTmpAllocZ
#define RTMemRealloc MLDMemRealloc
#define RTMemFree MLDMemFree
#define RTMemTmpFree MLDMemTmpFree
#endif /* VBOX_WITH_MLD_MEMLEAK_DETECTOR */
#endif // ____H_LOGGING
/* vi: set tabstop=4 shiftwidth=4 expandtab: */