![]() |
Development Lifecycle »
Debug Tips »
Trace
Intermediate
LogDispatch - debug moduleBy Gediminas SiutilasAnother debug module for your project (debug/release version). |
VC6, VC7, VC7.1Win2K, WinXP, Win2003, STL, Dev, QA
|
|
Advanced Search |
|
|
|
||||||||||||||||

Can you imagine the programming process without the possibility of debugging program code at run-time? It is obvious that such programming may exist, but programming without debugging possibility is too complicated when we are working on big and complex projects. In addition to standard approaches of debugging program code such as an output window on Visual Studio IDE or the macros of asserts, I propose a not new method for debugging your code: to output your debugging data to an application which is separated from Visual Studio IDE and the project you are currently working on.
Launch the application of trace messages catcher (next: trace catcher) before you start working with this module. Tracing data, sent to the trace catcher application, will be saved if the catcher application was inactive or was terminated during the trace operations. All the data which have been saved during the critical situations, as described above, will be kept and popped-out to trace catcher application when it starts again. There�s a possibility to start the trace catcher application with the creation of the trace module, and terminate it when the trace module is being destructed.
As I mentioned, this trace module allows you to put your trace data to several output windows in trace catcher application (next: trace channels). Trace channel is a simple window which helps to visualize your tracing data by the trace catcher application. In order to add your trace data to a certain trace channel, you must describe it as follows:
_Log.setSectionName( "channel_#1" ); _Log.dump( "%s", "My trace data" );
or
_Log.dumpToSection( "channel_#1", "%s", "My trace data" );
If you send your trace data to the new trace channel which is not created in the trace catcher application, new trace channel will be created automatically.
In addition to sending your trace data to the catcher, there�s a possibility to manipulate the trace catcher application with commands help. Commands are divided into two parts: global commands, and commands which depend to the trace channel.
closeRoot � close the trace catcher application;
onTop.ON � enable always on top state for the catcher application;
onTop.OFF � disable always on top state for the catcher application. Example:
_Log.sendCmd( "closeRoot" ); _Log.sendCmd( "onTop.ON");
clear - deleting the entry of given trace channel;
close - closing the given trace channel;
save <path to output stream> - saving the entry of the given trace channel to output stream described by you. Example:
_Log.sendCmd( "Channel_1", "clear" ); _Log.sendCmd( "Channel_2", "save c:\\channel2.log" ); _Log.sendCmd( "close" ); /** close the current output window (section) */
In order to fully use this trace module, you have to do only two steps:
An example:
#include "path_by_you\LogDispathc.dir\LogDispath.h"</pre>
To call all this messages described below, you must use variable names as follows: [_Log]. The trace object is created once during the project life-time (using singleton pattern).
Let's say, calling the dump message will be described like that:
_Log.dump( "System time is %d %d %5.5f ", 15, 10, 08.555121 );
dump � formatted trace data (sprintf format) are sent to catcher application. The tracing data will be placed to the section named as the result of calling method "setSectionName" before that, or if the method "setSectionName" wasn�t called, tracing data will be placed to the default section named as "output@default".
dumpToSection � the principle is the same as dump message. The difference is that this message will place your data to the channel by name which you described in this message.
setSectionName � set the working (active) channel name. getCmdPrefix � sets the prefix of the command.
setCmdPrefix � returns the prefix of the command.
sendCmd � sends your message to the receiver application.
setCloseOnExit � enables/disables the possibility to send the message to the catcher application on exit.
setCloseCMDOnExit � sets the command of the catcher application which will be send when the trace module will be destroyed. setClassNameOfCatcher � set the class name of the catcher application. That class name will be used in search of the catcher application where the tracing data will be sent.
runCatcher � executing the catcher application from the described path. This trace module and the strategy we are using on it is very flexible, and is an effective trace tool for debugging big projects. In my opinion, this tool will be a very effective strategy to trace release versions of the projects where all debugging data are removed. Very easy and comfortable to use it :].
| You must Sign In to use this message board. | |||||||||||||||
|
|||||||||||||||
|
|||||||||||||||
|
|||||||||||||||
|
|||||||||||||||
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 16 May 2004 Editor: Smitha Vijayan |
Copyright 2004 by Gediminas Siutilas Everything else Copyright © CodeProject, 1999-2009 Web15 | Advertise on the Code Project |