Click here to Skip to main content
Click here to Skip to main content
Go to top

Runtime Trace

, 30 Mar 2003
Rate this:
Please Sign up or sign in to vote.
Display trace messages at runtime from several running applications on different machines.

Sample Image

Purpose

Developing complex applications involves a large amount of time spent on bug crushing. Even after you think that everything is ok - and pass to the final release - the soft might throw some surprise errors, invisible while debugging. I present here an application designated to receive TRACE messages from runtime throwers, and two alternatives of sending such messages.

The receiver

This aim is to display trace messages received from several running applications. It will associate to each application, its own trace child window and will identify it by a string like this:

machine [application description]

where machine is the computer where the sending application is running and application description is a short description of the application itself. All you have to do is to start this application and to set the port where you want to listen from senders. The implicit value is 7777 and it's not recommended to modify it, unless it's already used.

The sender

Using the COM

You may instantiate it by Version Independent ID Tracing.RuntimeTrace, or by importing directly from tracing.dll, which can be found in the system directory. It depends on the developing instrument you are using. The interface has several methods and a property:

BOOL SetTarget (Name[, IP[, Port]] )
  • Name - the string to identify the current application
  • IP - the IP of the machine running the receiver. Default: "127.0.0.1"
  • Port - the port the receiver is listening. Must be the same value the receiver is listening

Attempts to connect the server and assigns a name to the sender application. Returns TRUE if successful, otherwise FALSE.

BOOL IsConnected ()

Returns TRUE if connected, otherwise FALSE.

BOOL Add (Var)
  • Var - The parameter to be added to the list

Adds a variable to the list to be traced. The order of calls must fit the order of the format text passed to the next Trace call. Returns TRUE if successful, otherwise FALSE.

VOID Drop()

Drops the content of the actual parameters list.

BOOL Trace(Format)
  • Format - the format text to be displayed by the receiver. Must be in printf (C function) style

Trace the list previously created with Add. Returns TRUE if successful, otherwise FALSE.

VOID Trace10(Format[, v1[, v2[...[, v10]]...])
  • Format - the format text to be displayed by the receiver
  • v1-v10 - at most 10 parameters to be traced

Trace the variables provided. Must be in printf (C function) style.

ErrorReason

A text containing the reason of the last error

Using RTClass.h (C++/MFC) or RTClassC.h (C++/non MFC)

Contains a class with the equivalent members of the COM interface above.

The protocol

machine "application" text

where machine is the IP of the sender machine, application is the name chosen for the application and text is the text the sender wishes to send. Notice the use of " as syntax element.

Updated

  • March 31, 2003

    Unicode support added.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Hans Ruck
Software Developer (Senior)
Europe Europe
No Biography provided

Comments and Discussions

 
Questionwell done! what about search feature? Pinmembermatro28-Jul-03 8:09 
this is a well written and useful logging tool; I'm thinking about implementing it on my software.
 
what about a search tool in the Runtime Trace app? a synchronized scrolling feature could also be extremely helpful.
 
thank you!

 
----
matro Smile | :)
 
www.realpopup.it
AnswerRe: well done! what about search feature? PinmemberBogdan Rechi29-Jul-03 2:54 
GeneralRe: well done! what about search feature? Pinmembermatro31-Jul-03 22:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 31 Mar 2003
Article Copyright 2002 by Hans Ruck
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid