Debugging and Configuration
Overview
Developers may encounter some errors when integrating the SDK. The SDK outputs relevant error logs. Developers can configure the log output level as needed and set error log pop-ups.
The SDK supports calling interfaces to view the current version.
Example Source Code Download
Please refer to Download Example Source Code to get the source code.
For relevant source code, please view files in the "src/Examples/DebugAndConfig/LogAndVersionAndDebug" directory.
Prerequisites
Before using log-related functions, please ensure:
- You have created a project in the ZEGOCLOUD Console and applied for a valid AppID and Server address. For details, please refer to Console - Project Information.
- You have integrated ZEGO Express SDK in your project and implemented basic audio/video Stream Publishing and Playing functions. For details, please refer to Quick Start - Integration and Quick Start - Implementation.
Usage Steps
Create Engine
Create a ZegoExpressEngine engine instance, pass the applied AppID to the "appID" parameter, and pass the access server address to the "server" parameter.
- "server" is the access server address. For how to obtain it, please refer to Console - Project Information.
- For SDK version 3.6.0 and above, server can be changed to an empty string, null, undefined, or any random character, but cannot be left empty.
// Initialize instance
const zg = new ZegoExpressEngine(appID, server);Set Log Level
Call the setLogConfig interface and use the "logLevel" property in the ZegoLogConfig object to set the log level printed to the local console.
| Property | Log level |
|---|---|
logLevel | The following levels increase sequentially from top to bottom. The higher the level, the fewer logs are printed:
|
const config = {
logLevel: 'debug',
};
zg.setLogConfig(config);2.2 If you want to set the log level before initializing the engine, you can set the log level printed to the local console through the "logLevel" property in the object set by the presetLogConfig interface.
ZegoExpressEngine.presetLogConfig({
logLevel: 'disable'
)(Optional) Enable Error Message Pop-ups
Call the setDebugVerbose interface after initialization and before logging into the Room to set whether to enable error log message pop-ups, used to prompt errors during development. It is enabled by default in the test environment and disabled by default in the production environment. It is recommended to keep the default configuration.
When the log level is set to "report" and "disable", no pop-up will appear.
// Enable error message pop-ups
zg.setDebugVerbose(false)View SDK Version Number
Call the getVersion interface to get the SDK version number currently in use.
zg.getVersion()