logo
Video Call
On this page

Debug and Config

2023-11-20

Introduction

Developers will encounter some errors when integrating the SDK. The SDK will output relevant error logs, and developers can configure the log input path and single log file size as needed.

In addition, the SDK supports calling interfaces to view the current version.

Download Sample Source Code

Please refer to Download Sample Source Code to obtain the source code.

For related source code, please check the files in the "/ZegoExpressExample/Examples/DebugAndConfig/Setting" directory.

Prerequisites

Before using log-related features, ensure that:

Usage Steps

Set log properties

Before creating the engine, you can set log properties by calling the setLogConfig interface.

Taking setting the log storage path to "/Users/zego/Log/log.txt" and the single log file size limit to 5 MB as an example:

ZegoLogConfig logConfig;
// Set log storage path
logConfig.logPath = "/Users/zego/Log/log.txt";
// Set single log file size limit
logConfig.logSize = 5242880L;
ZegoExpressSDK::setLogConfig(logConfig);

Among them, ZegoLogConfig contains log-related settings (save path and file size limit), and the specific definition is as follows:

struct ZegoLogConfig
{
    // Log file save path
    std::string logPath;

    // Log file size limit (Bytes), default is 5 MB (5 * 1024 * 1024 Bytes)
    unsigned long long logSize;

    ZegoLogConfig(){
        logSize = 5 * 1024 * 1024;
    }
};

Create engine

Define the SDK engine object, call the createEngine interface, pass the applied AppID and AppSign into the parameters "appID" and "appSign", and create the engine singleton object.

If you need to register a callback handler, you can pass an object that implements IZegoEventHandler into the parameter "eventHandler". If you do not need to register a callback handler, you can pass "null" into the parameter "eventHandler". After creating the engine, if you still need to register a callback, you can set the callback handler by calling the setEventHandler interface.

// Define SDK engine object
IZegoExpressEngine *engine = nullptr;

ZegoEngineProfile profile;
// AppID and AppSign are assigned to each App by ZEGO; for security reasons, it is recommended to store AppSign in the App's business backend and obtain it from the backend when needed
profile.appID = appID;
profile.appSign = appSign;
profile.scenario = ZegoScenario::ZEGO_SCENARIO_DEFAULT;
// Create engine instance
engine = ZegoExpressSDK::createEngine(profile, nullptr);

(Optional) Enable debug assistant

It is recommended to call the enableDebugAssistant interface during the development and debugging phase to enable the SDK's debug assistant feature. When subsequently calling other SDK interfaces, it will not only output logs to the console, but also pop up a reminder when interface call errors occur, making it convenient for developers to discover problems and correct them in time.

Warning

When development is completed and before the App is about to go online, please be sure to turn off this feature to avoid UI popups when potential errors occur in the online environment.

engine->enableDebugAssistant(true);

Get SDK version number

Call the getVersion interface to get the SDK version number. Developers can use the SDK version number information as the version information of the Engine used by the App, so as to count the versions of SDK corresponding to each version of App online.

engine->getVersion();
Note

During the operation of the SDK, when developers find that the actual situation does not match expectations, they can submit the problem and relevant logs to ZEGO Technical Support for positioning. ZEGO Technical Support may need the version information of the engine to assist in positioning the problem.

How to set and get SDK logs and stack information?

2023-11-20

Previous

Integration with ZEGO Effects SDK

Next

Usage Restrictions

On this page

Back to top