Log a printf-style string in a slog2 buffer
#include <slog2.h> int slog2fa( slog2_buffer_t buffer, uint16_t code, uint8_t severity, const char* format, ... );
- The handle of the buffer you want to log the message in, or NULL to use the default buffer that you specified earlier with slog2_set_default_buffer().
- A user-specified code that you want to be associated with the message. The slog2 system doesn't interpret this code in any way.
- The severity level of this log item; one of:
For more information, see the entry for slog2_register().
- A printf-formatted character string used to define the log message.
- Additional arguments
- An argument vector that specifies the arguments for the format string. You must use the appropriate SLOG2_FA_*() helper macro for parameters, as described below. The last parameter in the vector must be SLOG2_FA_END.
Use the -l slog2 option to qcc to link against this library.
The slog2fa() function a printf-style format string along with its arguments specified in the argument vector. This function uses special formatting macros to ensure that va_args() doesn't trigger any interrupts. The format string isn't decoded before writing; it must be decoded during the time of the read.
If you're specifying a string with %s, the size must include the NULL character.
You can use the following macros to build the parameters to slog2fa:
- SLOG2_FA_UNSIGNED( x )
- SLOG2_FA_SIGNED( x )
- SLOG2_FA_CHAR( x )
- SLOG2_FA_FLOAT( x )
- SLOG2_FA_DOUBLE( x )
- SLOG2_FA_STRING( x )
- SLOG2_FA_END — you must end the list with this macro
int8_t some_number = -1; slog2fa( ..., "string:%s, some_number:%d", SLOG2_FA_STRING( "Hello world" ), SLOG2_FA_SIGNED( some_number ), SLOG2_FA_END );
0 on success, or -1 if an error occurred.
|Interrupt handler||Read the Caveats|
Don't use double or float arguments in an interrupt handler, unless your code is compiled to use software floating-point emulation.
Last modified: 2014-06-24