DebugSession provide a way to control what and when text send through the cdebug stream is printed. cdebug display selectively the trace/debug messages between a minLevel and a maxLevel :
DebugSession manage a stack of (min,max) pairs so multiple session can be opened. On opening a new session the (min,max) pair is pushed on the top of the stack and define the active range of trace levels. On closing, the pair is removed from the top and the previous range became active again. Do not forget to match any opening with a closing.
In addition to the levels, a DebugSession also can be triggered by a symbol (i.e. a (void*) pointer). The DebugSession has contains a user managed table of symbols. When, in opening a session, you give a symbol, the session will actually changes the trace levels only if the symbol is in the internal table. Otherwise a session is still opened but it will keep the current trace levels. So, in any case the session must be closed.
Trace Levels
To avoid mixing messages between different parts of the software, the following allotments have been done:
Change the current debug level to (minLevel,maxLevel) only if symbol is traced. If the symbol is traced, then the new levels pair is stacked, otherwise the current level are stacked (we duplicate the top of the stack). This session, successful or not, must be closed as any other.