Skip to main content

Log File Setting

Introduction

These functions are responsible for setting the log from a camera.

HelloVizionSDK

Function:

void HelloVizionSDK()

Function Description:

  • This function is used to get the version of the VizionSDK from the log.

Parameter Description:

  • This function does not take any input parameters.

Example:

HelloVizionSDK();
// Hello VizionSDK!
// Version: {VizionSDK Version}

VxSetLogFile

Function:

int VxSetLogFile(const std::string& folderPath)

Function Description:

  • This function is used to set the destination path where to save the log file.

Parameter Description:

  • folderPath : A string constants of folder path.

  • Return : return 0 = PASS, return -1 = FAIL.

Example:

const std::string folderPath = "LOG_PATH";
// set the destination path of log file
VxSetLogFile(folderPath);

VxSetLogLevel

Function:

void VxSetLogLevel(VX_LOG_LEVEL level)

Function Description:

  • This function is for setting the log level, determining the verbosity of log messages.

Parameter Description:

  • level : The parameter is a VX_LOG_LEVEL variable that represents the level of the log.

    info

    Logging levels follow an order from low to high, meaning that setting a specific level enables logging for that level and all higher severity levels.

  • VX_LOG_LEVEL format:

    // Ordered from Low to High
    enum class VX_LOG_LEVEL {
    VX_LOG_LEVEL_TRACE,
    VX_LOG_LEVEL_DEBUG,
    VX_LOG_LEVEL_INFO,
    VX_LOG_LEVEL_WARN,
    VX_LOG_LEVEL_ERROR,
    VX_LOG_LEVEL_CRITICAL,
    VX_LOG_LEVEL_OFF,
    }

Example:

// Set the log level to information level
VxSetLogLevel(VX_LOG_LEVEL::VX_LOG_LEVEL_INFO);

Explanation of Levels(Ordered from Low to High):

  • VX_LOG_LEVEL_TRACE : Provides the most detailed logging, capturing step-by-step execution flow.
  • VX_LOG_LEVEL_DEBUG : Includes debugging information for developers, offering insights into internal operations and variable states.
  • VX_LOG_LEVEL_INFO (Default) : Logs general operational events, such as initialization, configuration changes, and so on.
  • VX_LOG_LEVEL_WARN : Highlights potential issues that do not immediately impact functionality.
  • VX_LOG_LEVEL_ERROR : Captures critical issues that disrupt specific functionalities but do not cause system-wide failure.
  • VX_LOG_LEVEL_CRITICAL : Logs severe errors that may lead to system or application failure, requiring urgent attention.
  • VX_LOG_LEVEL_OFF : Disables all logging, preventing any messages from being recorded.

VxSetLogCallback

Function:

void VxSetLogCallback(VxLogCallback callback, void* userData)

Function Description:

  • This function registers a callback to receive SDK log messages. Once set, the callback is invoked for every log message at or above the current log level.

Parameter Description:

  • callback : A function pointer matching the VxLogCallback signature:

    using VxLogCallback = void (*)(VX_LOG_LEVEL level, const char* message, void* userData);
  • userData : An arbitrary pointer passed back unchanged to the callback on every invocation. Pass NULL / nullptr if not needed.

  • Return : This function does not return a value.

Example:

void MyLogHandler(VX_LOG_LEVEL level, const char* message, void* userData) {
std::cout << "[SDK] " << message << std::endl;
}

// Register the log callback
VxSetLogCallback(MyLogHandler, nullptr);

VxClearLogCallback

Function:

void VxClearLogCallback()

Function Description:

  • This function unregisters the currently active log callback. After this call, SDK log messages are no longer forwarded to the previously registered callback.

Parameter Description:

  • This function does not take any input parameters.

  • Return : This function does not return a value.

Example:

// Unregister the log callback
VxClearLogCallback();