Example Code

Debug Tools for WebVI

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • G Web Development Software
  • LabVIEW NXG
  • LabVIEW NXG Web Module

Code and Documents

Attachment

Description

 Debug Tools for WebVIs (https://bit.ly/debugtools) provides VIs that can be used along with existing debugging techniques to help debug web applications (WebVIs) created with G Web Development Software 2021. The following nodes are included:

 

photo.jpg

 

Debug Log VI

 

The Debug Log VI is capable of taking any value passed to the value terminal and will print a representation to the console. When used inside the G Web Development Software editor the value is printed as a JSON string to the View >> Output pane similar to the Write to System Log VI. When used in a browser the value is printed to the console as an object that can be expanded and interactively explored to find specific fields or values. See the "How to Use" section for more usage details.

 

Note: The Debug Log VI should not be left in production applications. Values printed to the log are available in the console until the WebVI is closed. Continuously printing values using Debug Log VI will grow memory usage similar to a memory leak. The Debug Log VI should only be used in an WebVI while debugging.

 

Note: The console representation of values printed by the Debug Log VI should not be considered stable and is for debug use only. The console representation may be lossy (have reduced precision compared to the value in memory) and may change in the future without notice. The representation printed by the Debug Log VI should only be used for debugging.

 

How to Use

Once the attached NI package is installed and available in G Web Development Software, the following sections demonstrate how to use the included VIs:

 

Debug Log VI

 

The following GIF shows the process of including a Debug Log VI call in an existing application as well as how to find the printed console log in the View >> Output pane of G Web Development Software and how to find the console inside of a Web Browser (the GIF shows the process for Google Chrome but a console debug tool should be available in most browsers):

 

photo.jpg

 

In addition the following GIF demonstrates how to leverage the prefix terminal of the Debug Log node which can be used to create a string at the start of a console message for searching inside of the View >> Output pane or by using filtering options built-in to the browser console log tools (the GIF shows the process for Google Chrome but most browsers have similar console log filtering features):

 

photo.jpg

 

Additional Information

Notes for legacy LabVIEW NXG 5.1 users:

  • The Output pane is opened from the Project Files Pane under Tools Launcher >> Output for LabVIEW NXG
    photo.jpg

 


Milan

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
Daniel.Parrott
NI Employee (retired)
on

This is awesome!

Daniel Parrott
Software Product Marketing - Data Management & LabVIEW
National Instruments
Jens_S
Member
Member
on

Thanks for this nice little tool, helped me a lot!

Contributors