-
Notifications
You must be signed in to change notification settings - Fork 16
Traces
The new macros "Trace" and "TraceBuffer" support printf-style parameter lists.
Trace(ZONE_INFO, "int parameter %s hat den wert %d", "myInt", myInt);
The first parameter of the macro specifies the "debug zone". Use:
- ZONE_ERROR for trace messages in case of an error, in normal operation they should occur in rare situations only.
- ZONE_WARNING if something went wrong, but the system can recover. Happens more often than ZONE_ERROR but less than ZONE_INFO
- ZONE_INFO to informations even in the normal operation cases. F.e. to show state transitions ("device connected")
- ZONE_VERBOSE to display details, which would spam your output, if you enable it for all situations.
Use the second and next parameters as you would do in printf().
You have to declare 'g_DebugZones' in all your .c/.cpp files, where you want to use the new trace macros f.e.:
static const uint32_t g_DebugZones = ZONE_ERROR | ZONE_WARNING | ZONE_INFO | ZONE_VERBOSE;
Search ComProxy.cpp and WiflyControl.cpp for more examples on how to use these macros.
To enable only error messages use:
static const uint32_t g_DebugZones = ZONE_ERROR;
Or disable tracing in this module:
static const uint32_t g_DebugZones = 0;
DON'T FORGET 'static'. You need it to restrict the scope of 'g_DebugZones' to your current compilation unit.
Why don't use a global g_DebugZones for the whole program? Because it is very common, that you want to see details only for a small scope(class), f.e. while you are debugging class a you need to see all the messages even ZONE_VERBOSE, but activating it for all files would spam your output with verbose messages from all your other files.