High Performance OPC UA Server SDK
1.7.1.383
|
The SDK has built-in trace support which is helpful for analyzing problems.
Trace Checklist:
TRACE_ENABLED
is ON
, which is the SDK's default setting.TRACE_BACKEND
is selected:fprintf(stderr, ...)
.syslog
command (see man(3) syslog). This backend is for Linux and other UNIX like systems.trace_openlog()
, which allows filtering by facility
and trace level
.Our example applications offer command line switches to change the trace settings.
Listing available trace levels:
By default, the applications only enable TRACE_LEVEL_ERROR
and TRACE_LEVEL_WARNING
. If you want to enable more trace levels, you can use the command line switch -d
.
By using the switch -f
you can filter the output for the specific component e.g. TRACE_FAC_MEMORY
.
Note that traces TRACE_LEVEL_ERROR
ignore the facility filter and will always be shown.
By default the SDK does not trace sensitive data like usernames and passwords. It uses special trace macros like TRACE_USERNAME, TRACE_PASSWORD, TRACE_IPv4 and TRACE_IPv6 to trace sensitive data. It is recommended that you use these macros too when you need to trace sensitive information in your own code. This avoids leaking information when a trace file is e.g. sent by mail.
Instead of tracing the content these macros output 'XXX' or <hidden>
by default, no matter what trace level you have configured. You must explicitly enable this content by calling trace_change_security_level(). This avoids accidentally leaking sensitive information by using TRACE_LEVEL_DEBUG, ALL or similar.
When using the file trace backend, this backend reads in its own configuration file trace.conf
. This configures the trace file name, directory, and trace file rotation.
The parameters are described in the file itself.
Example trace.conf:
On Linux the stderr trace backend uses color output by default to make the trace better readable. On Windows this is disabled by default because Windows is lacking a proper terminal with color support. If you want to disable color support from the backend you can disable the CMake option ENABLE_COLOR
, then the trace backend will be built without color support.
When opening redirected output in primitive editors these colors might not get displayed correctly. In this case you can strip the color information (ANSI escape sequences) from the text files.
Using this Perl script you can remove the ANSI escape sequences from a file.
colorstrip.pl:
Usage:
When you have a trace file without colors and you want to add those nice colors afterwards you can use the following little Perl script.
This script can also easily be extended to perform filtering operations or highlighting other useful information like e.g. NodeIds.
For the Vim Editor there is a simple script which enables support for ANSI escape sequences. This makes the colors show up correctly in Vim.
Download: https://github.com/powerman/vim-plugin-AnsiEsc
Using a plugin manager like e.g. Vundle you need to add this line to your plugin config
and install using :VundleInstall
.
After opening a file you can type :AnsiEsc
to enable processing of the ANSI escape sequences. You can also automate this by adding the following snippet to your ~/.vimrc
.