Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Runtime Trace

0.00/5 (No votes)
30 Mar 2003 1  
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.

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