Logging API interfaces

Description

The following API functions are declared in logger.h. Modules requiring logging must include this header file. The header file contains the datatype:

Methods

In addition to the method references, logger.h also contains the datatype:

typedef struct logger_context logger_context;




log_open

Description

Initializes RAPLogging. This method must be called before any other API in the RAPLogging API. This method should be called only once.

Syntax

uint16_t log_open( char * filepath , uint16_t log_level);

Parameters

char * filepath

The name and location of the log file. The file path can be either relative or absolute.

Uint16_t log_level

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.

Returns

uint16_t error_code (an error code) or ERR_NONE (value 0).




log_message

Description

Writes the logging message and level into the log file.

Syntax

uint16_t log_message( uint16_t log level, uint16_t err_number, char * message);

Parameters

log level

Only the log levels defined in the “Logging levels” section are valid values.

err_number

Error number.

char * message

Message to be written out.

Returns

uint16_t error code (an error code) or ERR_NONE (value 0).




log_close

Description

Close the log file and log hierarchy. The clog_close method must be called after other log operations and must be called only once.

Syntax

vuint16_t  log_close();

Returns

uint16_t error_code (an error code) or ERR_NONE (value 0).




log_get_context

Description

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.

Syntax

logger_context * log_get_context( ); 

Returns

logger_context * A pointer to the logger_context used by the current RAPLogging instance.




log_init_from_context

Description

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:

In your shared library function:

Syntax

uint16_t log_init_from_context( logger_context * ctx  );

Parameters

logger_context * ctx

The logger_context pointer to be used to initialize the RAPLogging in a shared library.

Returns

uint16_t error_code (an error code) or ERR_NONE (value 0).




log_message_force

Description

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.

Syntax

uint16_t log_message_force( uint16_t level, uint16_t err_num, const char * message );

Parameters

log level: error number.

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.

err_number

error number.

char * message

The message to be written out to the log.

Returns

uint16_t error code (an error code) or ERR_NONE (value 0).




log_hexdump

Description

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    ======== 

Syntax

log_hexdump (char * contextString, void * address, long length)

Parameters

contextString

The string printed at the beginning and end of the trace segment for identification.

address

The beginning of the memory to dump.

length

The number of bytes to log.

Returns

uint16_t error_code (an error code) or ERR_NONE (value 0).