Updated on 2024-07-30 GMT+08:00

Setting the Path for Saving Logs

SetLogPath

API Description

This API is used to set the path for saving logs.

Precautions

  1. This API is optional. If it is not called, the default path is used.
  2. This API is an asynchronous API. The return value only indicates whether the API is successfully called. The actual service processing result is returned in the corresponding callback function.

Method Definition

HWM_SDK_AGENT_API hwmsdk::HwmErrCode SetLogPath(const HwmLogPathInfo* logPathInfo);

Callback Function

virtual void OnSetLogPathResult(hwmsdk::HwmErrCode ret, const char* reason) {};

Parameter Description

Table 1 HwmLogPathInfo description

Parameter

Mandatory

Type

Description

path

Yes

char[]

Save path.

UTF-8 encoding is required.

Table 2 Return value

Type

Description

HwmErrCode

If 0 is returned, the operation is successful. If other values are returned, the operation fails. For details about values returned upon failures, see Common Error Codes.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
/**
*  Set the path for saving logs.
*/
void demoSetLogPathDlg::SetLogPath()
{
    HwmLogPathInfo logPathInfo{};
    std::string path = "E:\\";
    strcpy_s(logPathInfo.path, sizeof(logPathInfo.path), path.c_str());
    int ret = hwmsdkagent::SetLogPath(&logPathInfo);
    if (hwmsdk::HWM_COMMON_SUCCESS != ret)
    {
        AfxMessageBox(_T("set log path error"));
        return;
    }
    CDialogEx::OnOK();
}