Text messages

Russell Taylor edited this page Apr 2, 2015 · 1 revision

VRPN objects communicate human-readable information, warning and error messages by sending vrpn_Text messages. Every VRPN object that is derived from vrpn_BaseClass knows how to emit these messages. Application code and objects can register handlers for these messages directly, using the vrpn_Text classes described in vrpn_Text.C, but there is also a vrpn_TextPrinter class that will watch objects and print messages that they send.

There is a global vrpn_System_TextPrinter object that is created within any application that uses VRPN and attaches itself to any object created. By default, it prints all warning and error messages sent by any object (or its associated server). This object is described in vrpn_BaseConnection.C. It has methods to allow the application to adjust the level of messages that it will print, and to change the ostream that is used to print messages (a NULL ostream pointer will cause the object not to print messages). It sends messages to cout by default. You can hush it up by calling set_min_level_to_print(vrpn_TEXT_ERROR, 10000) so that it will only print errors of level 10000 or more. You can also hush it up using set_ostream_to_use(NULL).

It is also possible for users to create their own text printing objects and attach various VRPN objects to them, so that only messages from those devices are printed. You can then create a new vrpn_TextPrinter object, specify what stream it writes to, specify its error/warning level, and stick only the objects you want into it. Or, you can register callbacks directly on the text messages for the objects you want and filter them however you like. The disconnect-from-server messages have the severity equal to the time it has been since the connection was dropped, to try and make this easier for you.

This won't affect the messages from the connection objects saying that connections have been dropped and opened; they are currently hard-coded into the connection code.