Debugging and Configuration
Feature Introduction
Developers will encounter some errors when integrating the SDK. The SDK will output relevant error logs. Developers can configure the log output path and single log file size as needed.
In addition, the SDK supports calling interfaces to view the current version.
Sample Source Code Download
Please refer to Download Sample Source Code to get the source code.
For related source code, please check the files in the "/ZegoExpressExample/Examples/Debug&Config" directory.
Prerequisites
Before using log-related features, please ensure:
- You have created a project in the ZEGOCLOUD Console and applied for a valid AppID and AppSign. For details, please refer to Console - Project Information.
- You have integrated the ZEGO Express SDK in the project and implemented basic audio and video publishing and playing functions. For details, please refer to Quick Start - Integration and Quick Start - Implementation Flow.
Usage Steps
1 Set log properties
Before creating the engine, you can set log properties by calling setLogConfig.
Taking setting the log storage path to "[[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingString:@"/ZegoLogs"]" and the single log file size limit to 5 MB as an example:
NSString *appLogPath = [[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingString:@"/ZegoLogs"];
ZegoLogConfig *logConfig = [[ZegoLogConfig alloc] init];
logConfig.logPath = appLogPath;
// 5 MB
logConfig.logSize = 5 * 1024 * 1024;
[ZegoExpressEngine setLogConfig:logConfig];Among them, ZegoLogConfig contains log-related settings (save path and file size limit), specifically defined as follows:
@interface ZegoLogConfig : NSObject
// Storage path of log files. Default path is [NSCachesDirectory]/ZegoLogs/
@property (nonatomic, copy) NSString *logPath;
// Maximum size of log file (Bytes) Default maximum size is 5 MB
@property (nonatomic, assign) unsigned long long logSize;
@end2 Create engine
Define the SDK engine object and call the createEngineWithProfile interface, passing the applied AppID and AppSign into the parameters "appID" and "appSign" to create the engine singleton object.
If you need to register a callback handler, you can pass the object that declares ZegoEventHandler into the parameter "eventHandler". If you don't need to register a callback handler, you can pass "nil" 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.
ZegoEngineProfile *profile = [ZegoEngineProfile new];
// Please obtain through official website registration, format: 1234567890
profile.appID = appID;
// Please obtain through official website registration, format: @"0123456789012345678901234567890123456789012345678901234567890123" (total 64 characters)
profile.appSign = appSign;
// General scenario access
profile.scenario = ZegoScenarioDefault;
// Create engine and register self as eventHandler callback. If you don't need to register callback, the eventHandler parameter can be nil, and you can call the "-setEventHandler:" method later to set callback
[ZegoExpressEngine createEngineWithProfile:profile eventHandler:self];3 (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 function. When subsequently calling other SDK interfaces, it can not only output logs to the console, but also pop up reminders when interface calls error, making it convenient for developers to discover problems at the first time and correct them in time.
When development is completed and before the App is about to go live, please be sure to disable this feature to avoid UI popups when latent errors occur in the online environment.
[[ZegoExpressEngine sharedEngine] enableDebugAssistant:YES];4 Get SDK version number
Calling getVersion can obtain the SDK version number. Developers can use the SDK version number information as the Engine version information used by the App, so as to count the versions of SDK corresponding to each version of App online.
When the SDK is running and developers find discrepancies with expected situations, they can submit the problem and relevant logs to ZEGO technical support for locating. ZEGO technical support may need the Engine version information to assist in locating the problem.
[ZegoExpressEngine getVersion];Related Documentation
How to set and get SDK logs and stack information?
