XVector
xvec_log.h File Reference

Log sink registration API for the XVector library. More...

#include <stdint.h>
#include "xvec_types.h"
Include dependency graph for xvec_log.h:

Go to the source code of this file.

Typedefs

typedef enum xvecLogLevel xvecLogLevel
 Log severity levels. More...
 
typedef void(* xvecLogSinkFn) (xvecLogLevel logLevel, const char *file, uint32_t line, const char *message, void *userData)
 Log sink callback function type. More...
 

Enumerations

enum  xvecLogLevel {
  XVEC_LOG_LEVEL_ERROR = 1 , XVEC_LOG_LEVEL_WARN = 2 , XVEC_LOG_LEVEL_INFO = 3 , XVEC_LOG_LEVEL_DEBUG = 4 ,
  XVEC_LOG_LEVEL_TRACE = 5
}
 Log severity levels. More...
 

Functions

xvecStatus xvecSetLogSink (xvecLogSinkFn logSink, void *userData)
 Sets the log sink callback function. More...
 
xvecStatus xvecSetLogLevel (xvecLogLevel logLevel)
 Sets the minimum log level for runtime filtering. More...
 
xvecLogLevel xvecGetLogLevel (void)
 Gets the current runtime log level. More...
 
const char * xvecGetLogLevelString (xvecLogLevel logLevel)
 Gets the string representation of a log level. More...
 
const char * xvecGetLogLevelColor (xvecLogLevel logLevel)
 Gets the ANSI color code for a log level. More...
 

Detailed Description

Log sink registration API for the XVector library.

This header provides the public API for registering custom log sink callbacks to receive log messages from the library.

Definition in file xvec_log.h.

Typedef Documentation

◆ xvecLogLevel

typedef enum xvecLogLevel xvecLogLevel

Log severity levels.

◆ xvecLogSinkFn

typedef void(* xvecLogSinkFn) (xvecLogLevel logLevel, const char *file, uint32_t line, const char *message, void *userData)

Log sink callback function type.

Parameters
logLevelSeverity level of the log message
fileSource file name where the log was generated
lineLine number in the source file
messageLog message string
userDataUser-provided context data passed to xvecSetLogSink

Definition at line 57 of file xvec_log.h.

Enumeration Type Documentation

◆ xvecLogLevel

Log severity levels.

Enumerator
XVEC_LOG_LEVEL_ERROR 

Error messages indicating failures.

XVEC_LOG_LEVEL_WARN 

Warning messages for potential issues.

XVEC_LOG_LEVEL_INFO 

Informational messages.

XVEC_LOG_LEVEL_DEBUG 

Debug messages for development.

XVEC_LOG_LEVEL_TRACE 

Detailed trace messages.

Definition at line 39 of file xvec_log.h.

Function Documentation

◆ xvecGetLogLevel()

xvecLogLevel xvecGetLogLevel ( void  )

Gets the current runtime log level.

Returns
xvecLogLevel The current minimum log level.

◆ xvecGetLogLevelColor()

const char* xvecGetLogLevelColor ( xvecLogLevel  logLevel)

Gets the ANSI color code for a log level.

Parameters
[in]logLevelThe log level.
Returns
const char* ANSI color escape sequence for the log level.

◆ xvecGetLogLevelString()

const char* xvecGetLogLevelString ( xvecLogLevel  logLevel)

Gets the string representation of a log level.

Parameters
[in]logLevelThe log level to convert.
Returns
const char* String representation ("ERROR", "WARN", "INFO", "DEBUG", "TRACE").

◆ xvecSetLogLevel()

xvecStatus xvecSetLogLevel ( xvecLogLevel  logLevel)

Sets the minimum log level for runtime filtering.

Only log messages with severity equal to or higher than the specified level will be passed to the log sink. This provides runtime control over log verbosity.

Parameters
[in]logLevelMinimum log level to output (XVEC_LOG_LEVEL_ERROR is highest priority).
Returns
xvecStatus
Return values
XVEC_SUCCESSOperation completed successfully.

◆ xvecSetLogSink()

xvecStatus xvecSetLogSink ( xvecLogSinkFn  logSink,
void *  userData 
)

Sets the log sink callback function.

Registers a custom callback function to receive log messages from the library. Pass NULL to disable logging output.

Parameters
[in]logSinkPointer to the log sink callback function, or NULL to disable.
[in]userDataUser-provided context data passed to the callback function.
Returns
xvecStatus
Return values
XVEC_SUCCESSOperation completed successfully.