Add ERR_, WARN_, TRACE_ and INFO_ macros which call DbgPrintEx

svn path=/trunk/; revision=31216
This commit is contained in:
Hervé Poussineau 2007-12-14 15:59:14 +00:00
parent 0ae8ce587f
commit 927f7b56aa

View file

@ -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
/*