acllogRegisterCallback

Applicable Products

Product

Supported

Ascend 950PR/Ascend 950DT

√

Atlas A3 training products/Atlas A3 inference products

√

Atlas A2 training products/Atlas A2 inference products

√

Atlas 200I/500 A2 inference products

☓

Atlas inference products

☓

Atlas training products

☓

Function

Registers a callback function for device plogs. After successful registration, the callback is triggered for device plogs before the original flushing process.

A maximum of 16 callback functions can be registered. The return values of the callback function are ignored, which neither affect the original plog flushing process nor the execution of other registered callback functions.

This API takes effect only for device plogs on the report link, not for AlogRecord/DlogRecord logs on the host.

Prototype

1
int32_t acllogRegisterCallback(acllogRecordCallback callbackFunc, void *userData, uint32_t outputLogType, acllogCallbackHandle *callbackHandle)

Parameters

Parameter

Input/Output

Description

callbackFunc

Input

Callback function. For details about the type definition, see Definitions of Data Types. NULL is not allowed.

userData

Input

User-defined data. The data is returned through the userData parameter of the callback function when the callback is triggered. NULL is allowed.

outputLogType

Input

Output log type received by the callback. For details about the enumerated values, see Definitions of Data Types.

callbackHandle

Output

Callback handle returned after successful registration, which is used for unregistration. NULL is not allowed.

Returns

Returns the callback registration result.

0: successful registration

-1: registration failure The failure scenarios include the following: callbackFunc is NULL, callbackHandle is NULL, outputLogType is invalid, and the number of registered callback functions reaches 16.

Example

static int32_t LogCallback(void *userData, uint32_t outputLogType, const char *logContent, size_t length)
{
    (void)userData;
    (void)outputLogType;
    printf("%.*s", (int)length, logContent);
    return 0;
}

acllogCallbackHandle handle = 0;
int32_t ret = acllogRegisterCallback(LogCallback, NULL, OUTPUT_TYPE_BOTH, &handle);