VR-Link C# API Documentation
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros Pages
13.5 - Diagnostic Utilities

Table of Contents

You can control the amount of diagnostic information printed by VR-Link by setting the global variable DtNotifyLevel, declared in vlPrint.h.

You can set DtNotifyLevel to any of the following values:

The default is DtNlInfo.

You can use the notify level to control messages generated by your own application as well, if you use VR-Link's printing functions rather than printf() or cout() directly. These printing functions are also declared in vlPrint.h, and have the same prototype as printf(). They include:

The fatal functions call DtAbort() after printing their messages.

13.5.1 Using DtOutputStream for Printing

DtOutputStream lets you send debug and informational messages in VR-Link. It uses a buffer and allows you to redirect messages. It works very much like any std::ostream class.

DtInfo, DtWarn, DtVerbose, DtFatal, and DtDebug are all DtOutputStream objects. As such, you can write to them just like any standard C++ output stream, for example:

DtInfo << "something bad just happened, the error is " << error << "\n";

DtOutputStream can attach to one or more DtPrinters. A DtPrinter can print to an output device. VR-Link includes the following DtPrinter subclasses:

By default the DtStdoutPrinter is attached to DtInfo, DtWarn, DtDebug, DtVerbose and DtFatal. You can add any of these subclasses, or your own subclass, to all, or just one of these streams to make DtInfo print to a file, for example:

DtFilePrinter info_log("myInfo.log");
DtInfo.attachPrinter(&info_log);

To print to a console, do the following:

DtInfo.attachPrinter(&DtStandardWindowsConsole)

13.5.2 Printing Diagnostic Messages in Windows

Windows applications that are not console-based do not define STDOUT in the usual way. For example, if you try to use cout or printf to debug a MAK plug-in or to debug VR-Link in an MFC application, it will not work unless you take special care to set up a console and write to it.

To avoid this problem, call the VR-Link function setFileOutput() (defined in vlPrint.h) to enable either writing to a console window or writing to a file. Then, to ensure that diagnostic output gets printed to either the console window or to the file, use VR-Link's printing functions: DtWarn(), DtWarnPerror(), DtInfo(), DtDebug(), and DtVerbose().

[<< Creating Linked Lists with DtList] [Home] [Top of Page] [The DtException Class >>]


Document ID: Generated on Mon Apr 25 03:39:01 EDT 2022 from SVN revision 242502
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)