From 927f7b56aac534a81dfe5371a2b79a68cbbee671 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Fri, 14 Dec 2007 15:59:14 +0000 Subject: [PATCH] Add ERR_, WARN_, TRACE_ and INFO_ macros which call DbgPrintEx svn path=/trunk/; revision=31216 --- reactos/include/reactos/debug.h | 44 ++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/reactos/include/reactos/debug.h b/reactos/include/reactos/debug.h index 9962df4682e..1863cf8d003 100644 --- a/reactos/include/reactos/debug.h +++ b/reactos/include/reactos/debug.h @@ -21,11 +21,14 @@ #define CHECKED #endif -/* Define DbgPrint/RtlAssert unless the NDK is used */ +/* Define DbgPrint/DbgPrintEx/RtlAssert unless the NDK is used */ #if !defined(_RTLFUNCS_H) && (!defined(_NTDDK_) || !defined(__NTDDK_H)) /* Make sure we have basic types (some people include us *before* SDK... */ -#if defined(_NTDEF_) || (defined _WINDEF_) || (defined _WINDEF_H) +#if !defined(_NTDEF_) && !defined(_WINDEF_) && !defined(_WINDEF_H) +#error Please include SDK first. +#endif + ULONG __cdecl DbgPrint( @@ -33,6 +36,15 @@ DbgPrint( IN ... ); +ULONG +__cdecl +DbgPrintEx( + IN ULONG ComponentId, + IN ULONG Level, + IN PCCH Format, + IN ... +); + NTSYSAPI VOID NTAPI @@ -42,7 +54,6 @@ RtlAssert( ULONG LineNumber, PCHAR Message ); -#endif #endif @@ -98,6 +109,28 @@ RtlAssert( #define UNIMPLEMENTED \ DbgPrint("WARNING: %s at %s:%d is UNIMPLEMENTED!\n",__FUNCTION__,__FILE__,__LINE__); + #if defined(__GNUC__) + #define ERR_(ch, args...) DbgPrintEx(DPFLTR_##ch##_ID, DPFLTR_ERROR_LEVEL, "(%s:%d)", __FILE__, __LINE__), \ + DbgPrintEx(DPFLTR_##ch##_ID, DPFLTR_ERROR_LEVEL, ##args) + #define WARN_(ch, args...) DbgPrintEx(DPFLTR_##ch##_ID, DPFLTR_WARNING_LEVEL, "(%s:%d)", __FILE__, __LINE__), \ + DbgPrintEx(DPFLTR_##ch##_ID, DPFLTR_WARNING_LEVEL, ##args) + #define TRACE_(ch, args...) DbgPrintEx(DPFLTR_##ch##_ID, DPFLTR_TRACE_LEVEL, "(%s:%d)", __FILE__, __LINE__), \ + DbgPrintEx(DPFLTR_##ch##_ID, DPFLTR_TRACE_LEVEL, ##args) + #define INFO_(ch, args...) DbgPrintEx(DPFLTR_##ch##_ID, DPFLTR_INFO_LEVEL, "(%s:%d)", __FILE__, __LINE__), \ + DbgPrintEx(DPFLTR_##ch##_ID, DPFLTR_INFO_LEVEL, ##args) + #elif defined(_MSC_VER) + #define ERR_(ch, ...) DbgPrintEx(DPFLTR_##ch##_ID, DPFLTR_ERROR_LEVEL, "(%s:%d)", __FILE__, __LINE__), \ + DbgPrintEx(DPFLTR_##ch##_ID, DPFLTR_ERROR_LEVEL, __VA_ARGS__) + #define WARN_(ch, ...) DbgPrintEx(DPFLTR_##ch##_ID, DPFLTR_WARNING_LEVEL, "(%s:%d)", __FILE__, __LINE__), \ + DbgPrintEx(DPFLTR_##ch##_ID, DPFLTR_WARNING_LEVEL, __VA_ARGS__) + #define TRACE_(ch, ...) DbgPrintEx(DPFLTR_##ch##_ID, DPFLTR_TRACE_LEVEL, "(%s:%d)", __FILE__, __LINE__), \ + DbgPrintEx(DPFLTR_##ch##_ID, DPFLTR_TRACE_LEVEL, __VA_ARGS__) + #define INFO_(ch, ...) DbgPrintEx(DPFLTR_##ch##_ID, DPFLTR_INFO_LEVEL, "(%s:%d)", __FILE__, __LINE__), \ + DbgPrintEx(DPFLTR_##ch##_ID, DPFLTR_INFO_LEVEL, __VA_ARGS__) + #else + #error Unknown compiler + #endif + #else /* On non-debug builds, we never show these */ @@ -107,6 +140,11 @@ RtlAssert( #define CHECKPOINT1 #define CHECKPOINT #define UNIMPLEMENTED + + #define ERR_(ch, ...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0) + #define WARN_(ch, ...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0) + #define TRACE_(ch, ...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0) + #define INFO_(ch, ...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0) #endif /*