Nios® V Processor Software Developer Handbook

ID 743810
Date 7/20/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

6.6.6.5. Custom Logging Messages

You can add custom messages that are sent to the Intel FPGA logging device. To define a custom message, include the header file alt_log_printf.h in your C source file as follows:

#include "sys/alt_log_printf.h"

Then use the following macro function:

ALT_LOG_PRINTF(const char *format, ...)

This C preprocessor macro invokes a pared-down version of printf(). The format argument supports most printf() options. It supports %c, %d, %I, %o, %s, %u, %x, and %X, as well as some precision and spacing modifiers, such as %-9.3o. It does not support floating point formats, such as %f or %g. This function is not compiled if Intel® FPGA logging is not enabled.

If you want your custom logging message to be controlled by Intel® FPGA logging preprocessor options, use the appropriate Intel® FPGA logging option preprocessor flags from the ALT_LOG_FLAGS Logging Levels table or the Intel FPGA Logging Options and Option Modifiers table.

Implementing Logging Options with Custom Logging Messages

/* The following example prints "Level 2 logging message" if
logging is set to level 2 or higher */
#if ( ALT_LOG_FLAGS >= 2 )
ALT_LOG_PRINTF ( "Level 2 logging message" );
#endif
/* The following example prints "Boot logging message" if boot logging
is turned on */
#if ( ALT_LOG_BOOT_ON_FLAG_SETTING == 1)
ALT_LOG_PRINTF ( "Boot logging message" );
#endif