Scripting in Application
In this article: User-defined scripts are supported by ULogViewer 2.0+. Each script is defined for specific purpose and will be executed when needed. For ex, log analysis. There are 3 scripting languages supported:Cancellation of Running Script
JavaScript
There is no need to take care of cancellation of running script because cancellation will be handled by JavaScript interpreter.C# Script and Python
It is the responsibility of script to check CancellationToken (C#) / is_cancellation_requested() (Python) periodically to abort the running script.
You can also use IsCancellationRequested global property in C# script starting from ULogViewer 3.0.
⬆️ Back to top
Debugging
Syntax Error
The syntax of script will be checked during editing. Therefore, all syntax error can be found in script editing UI:For C# script, incorrect reference to identifier can also be found while editing because ULogViewer do compilation for C# script but not for JavaScript:
Runtime Error
A error dialog will show when error occurred while running script. You can check the error message and the position of source code which causes the error to find the root cause. Sometimes the position of source code which causes the error cannot be determined for C# script. In this case, You will need to do further debugging by logging.Open Script Log WindowULogViewer 3.0+
Windows/Linux Users- Click at right hand side of toolbar.
- Click 'Tools > Script log window' in menu.
- Click 'Tools > Script log window' in menu at top of screen.
View Logs in ULogViewer
- Open a new tab.
- Select "ULogViewer Real-time Log" log profile.
Error Logs
You can find error log like this while running JavaScript in ULogViewer 3.0+:
Property 'getProperty_' of object is not a function [Line 1, column 0]
Before ULogViewer 3.0:
Error occurred while running analysis script of 'Test Script' (dkj1g2mf): [Line:1, Column:0] Property 'getProperty_' of object is not a function
For C# script, you can find error log like this in ULogViewer 3.0+:
Object reference not set to an instance of an object. [Line 1]
Before ULogViewer 3.0:
Error occurred while running setup script of 'Test Script' (dkj1g2mf): Object reference not set to an instance of an object.
The error message for C# script doesn't contain the position of source code which causes the error before ULogViewer 3.0. Therefore, you may need to find error by logging from script.
⬆️ Back to top
Logging
Logging is supported while executing script. For usage of logger please refer to Context.Logger for C# script / context.logger for JavaScript / log_*() global functions for Python。 The followings are supported log levels listed from highest priority to lowest:- Critical
- Error
- Warning
- Information
- Debug
- Trace