The following API functions are declared in logger.h. Modules requiring logging must include this header file. The header file contains the datatype:
In addition to the method references, logger.h also contains the datatype:
typedef struct logger_context logger_context;
Initializes RAPLogging. This method must be called before any other API in the RAPLogging API. This method should be called only once.
uint16_t log_open( char * filepath , uint16_t log_level);
The name and location of the log file. The file path can be either relative or absolute.
The log level defined in the configuration file. The log_level acts as filter, any message with lower log level will be ignored and not written into the log file. It can be defined in the configuration file as default filter value, or you can explicitly set the filter level dynamically.
uint16_t error_code (an error code) or ERR_NONE (value 0).
Writes the logging message and level into the log file.
uint16_t log_message( uint16_t log level, uint16_t err_number, char * message);
Only the log levels defined in the “Logging levels” section are valid values.
Error number.
Message to be written out.
uint16_t error code (an error code) or ERR_NONE (value 0).
Close the log file and log hierarchy. The clog_close method must be called after other log operations and must be called only once.
vuint16_t log_close();
uint16_t error_code (an error code) or ERR_NONE (value 0).
Returns a pointer to the logger_context used by current RAPLogging
instance. This
pointer can be used to initialize the RAPLogging
in
a shared library. For a description of steps needed to initialize RAPLogging
in
a shared library, see the “log_init_from_context”section.
logger_context * log_get_context( );
logger_context * A
pointer to the logger_context
used
by the current RAPLogging
instance.
Initializes the RAPLogging
from
an existing context that was created by a previous call to log_open()
.
This can be used to pass a logger instance to a shared library function.
This function must be called before any other API in the RAPLogging
API
is invoked in the shared library.
The following sequence of calls should be used in your main executable to pass a logger instance to a shared library:
Initialize the logger as usual by invoking log_open()
Get the pointer to the logger_context by invoking log_get_context()
Invoke your shared library function passing it the logger_context pointer.
In your shared library function:
Invoke log_init_from_context() passing it the logger_context pointer as the argument.
Invoke the log_message() function to log messages from your shared library.
uint16_t log_init_from_context( logger_context * ctx );
The logger_context pointer to be used to initialize the RAPLogging in a shared library.
uint16_t error_code (an error code) or ERR_NONE (value 0).
Write the logging message and level into the log file. This method forces the message into the log file regardless of the filter value of the log level. The filter value can be set in the configuration file (RAP) or explicitly set by calling log_open() on the feed handler side.
uint16_t log_message_force( uint16_t level, uint16_t err_num, const char * message );
Only the values defined in section “Logging levels” are valid. For this method, log level is used primarily as informational display in the log file, as the message will be always be written into the log file.
error number.
The message to be written out to the log.
uint16_t error code (an error code) or ERR_NONE (value 0).
Format and log a traditional memory dump starting at the address supplied and for the length supplied. Use the supplied context string at the top and bottom to make it easy to identify. Uses the internal logger-> debug function to write it to the current log file.
A typical dump file (with the date, time and thread values removed) looks like the following:
DEBUG rap4 - ===== DSHTable in Loader:Run New Work ======== DEBUG rap4 - 26583E0 >B0236800 00000000 C0C16502 00000000< .#h.......e..... 00000000 DEBUG rap4 - 26583F0 >36000700 00000000 90846502 00000000< 6.........e..... 00000010 DEBUG rap4 - 2658400 >58886702 00000000 F8C86E00 00000000< X.g.......n..... 00000020 DEBUG rap4 - 2658410 >F07E6502 00000000 707F6502 00000000< .~e.....p.e..... 00000030 DEBUG rap4 - 2658420 >687E6502 00000000< h~e..... 00000040 DEBUG rap4 - ===== DSHTable in Loader:Run New Work ========
log_hexdump (char * contextString, void * address, long length)
The string printed at the beginning and end of the trace segment for identification.
The beginning of the memory to dump.
The number of bytes to log.
uint16_t error_code (an error code) or ERR_NONE (value 0).