Logging and printf¶
VSI runtime has a modular logging system. This functionality is available to software executables that have been built using the ‘debug’ runtime build type. To select this build type:
- Open the VSI Context Parameters for the software context.
- Select the ‘Software Parameters’ tab.
- Under ‘C/C++ options’ set the Runtime Build Type to Debug.
Environment variables¶
Before running the software application, logging must be turned on using the following environment variables:
- VSI_LOG_LVL can be one of the following: CRIT, ERR, DBG, INFO, VERBOSE (case insensitive)
- VSI_LOG_COMPS can be either ALL or a list of components (case insensitive)
Examples¶
- Enable logging for all components and maximum logging env VSI_LOG_LVL=verbose VSI_LOG_COMPS=all ./executable
- Enable logging for all components and error logging only env VSI_LOG_LVL=err VSI_LOG_COMPS=all ./executable
- Enable logging for inputs and outputs components and debug logging only env VSI_LOG_LVL=dbg VSI_LOG_COMPS=inputoutput ./executable
- Enable logging for tcp_server_0_1 and Trace components and info logging env VSI_LOG_LVL=info VSI_LOG_COMPS=tcp_server_0_1trace ./executable
printf and puts¶
Often, printf and puts is used to debug C/C++ functions. In a multithreaded application with parallels paths, especially when debugging timing issues and parallel execution paradigms, it can become challenging to figure out which thread is printing.
VSI Runtime adds a helper template to printf and puts. {{tid}}
inside the formatting argument will be replaced by a unique ID for the current thread. For example,
printf("write to memory {{{tid}}}");
will be printed as
write to memory {12AE}
write to memory {A92F}
where 12AE and A92F are unique ids for two threads accessing the same function.