From: Dirk L. <di...@no...> - 2003-04-04 09:44:42
|
Hi, I would like to add tracing (function call hierarchy) to my application by adding a trace/log statement as a first command to each function call. The output should be formatted in a way, that there is an increasing indentation for each function call (and some possible following TRACE statments). The reason for this is, that I redirect all TRACE (::AfxTrace/afxDump in a WIN32/MFC app) messages to a "TRACE" category. I would like to add the function name and a calling depth to the output to better see the program flow and the context of the TRACE calls (there are some nice function that can print the called function and the parameters to produce something like a stackdump in the imagehelp.dll). My problem is the implementation of the indentation. It is very easy to add a automatic class that increases/decreases the indentation level during entering and leaving the function and adding the indentation to all TRACE calls. But I would be very good if I could add this information to all logging calls. I know, that there is the NDC for the purpose to store some global information for all following logging calls. But the NDC seems more like a place to store information about the state of the application, like current client/server pair, current state, and so on. Misusing the NDC to simply store two blanks during entering a function and removing these blanks during leaving seems to be like a performance kill. And you would not exactly loose the stored state information about the current thread but you will loose the nice formatting, since indentation spaces and stored information is mixed within the synthetizied NDC string. My question is, wether it would make sence to add a indentation level to the NDC and to the LoggingEvent? To the NDC, since there is always one NDC (?) per thread and therefore one central object for this type of information and to the LoggingEvent so that one can have control over the output of the indentation within the PatternLayout. Thanks for your answers Dirk |