Class CPBScopeLogger

CPBScopeLogger(PB_LOC_ARGS, ULONG ulMsgType, PCTSTR pszScope = NULL, CPBLogger* plgr = NULL)


Note that in the above prototypes the location macro PB_LOC_ARGS expands to PC[W]STR pszFile, ULONG ulLine.

pszFileSource code file name. Usually obtained via the __FILE__ preprocessor macro.

ulLineSource code line number. Usually obtained via the __LINE__ preprocessor macro.

ulMsgTypeOne of the message type constants.

pszScopeScope string to log. The string is prefixed with “Entering scope: ” when logged from the constructor and “Leaving scope: ” when logged from the destructor.

plgrPointer to a CPBLogger object to use for logging. Uses PBLog with default component and context if this is NULL.


The constructor prefixes the string referenced by the pszScope parameter with the string “Entering scope: ” and logs it using the CPBLogger object referenced by the plgr parameter or by calling PBLog using the default component and context if plgr is NULL. When the destructor is called it does the same but prefixes the scope string with “Leaving scope: “. Note that only a pointer to the string referenced by pszScope is stored - the string is not copied and therefore the string must still exist when the destructor is called.

Versions of this function are provided that accept either ANSI or Unicode strings. ANSI strings are always converted to Unicode when log messages are generated. Both versions are always simultaneously available in the lib to support explicit logging with mixed character sets.

Both functions are called using the location / type macros as follows:

VOID MyFunction()
CPBScopeLogger slgr(PB_VERBOSE, “MyFunction”);