Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
Optimize iOS logs. (#2896)
Browse files Browse the repository at this point in the history
  • Loading branch information
wqyfavor authored and jianhan-he committed Sep 11, 2019
1 parent 3d7ea0a commit 4ce557b
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 13 deletions.
5 changes: 5 additions & 0 deletions ios/sdk/WeexSDK/Sources/Manager/WXBridgeManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,8 @@ - (void)registerService:(NSString *)name withServiceUrl:(NSURL *)serviceScriptUr

- (void)registerService:(NSString *)name withService:(NSString *)serviceScript withOptions:(NSDictionary *)options completion:(void(^)(BOOL result))completion
{
WXLogInfo(@"Register service: %@, options: %@", name, options);

if (!name || !serviceScript || !options) {
if (completion) {
completion(NO);
Expand Down Expand Up @@ -557,6 +559,7 @@ - (void)unregisterService:(NSString *)name
{
if (!name) return;

WXLogInfo(@"Unregister service: %@", name);
NSString *script = [WXServiceFactory unregisterServiceScript:name];

__weak typeof(self) weakSelf = self;
Expand All @@ -575,6 +578,7 @@ - (void)registerModules:(NSDictionary *)modules
if (!modules) return;

modules = [WXUtility convertContainerToImmutable:modules];
WXLogInfo(@"Register modules: %@", modules);

__weak typeof(self) weakSelf = self;
WXPerformBlockOnBridgeThread(^(){
Expand All @@ -590,6 +594,7 @@ - (void)registerComponents:(NSArray *)components
if (!components) return;

components = [WXUtility convertContainerToImmutable:components];
WXLogInfo(@"Register components: %@", components);

__weak typeof(self) weakSelf = self;
WXPerformBlockOnBridgeThread(^(){
Expand Down
14 changes: 13 additions & 1 deletion ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ - (instancetype)initWithRenderType:(NSString*)renderType
}
}

WXLogInfo(@"Create instance: %@, render type: %@", _instanceId, _renderType);

// TODO self is retained here.
[WXSDKManager storeInstance:self forID:_instanceId];

Expand Down Expand Up @@ -206,6 +208,12 @@ - (NSString *)description
return [NSString stringWithFormat:@"<%@: %p; id = %@; rootView = %p; url= %@>", NSStringFromClass([self class]), self, _instanceId, (__bridge void*)_rootView, _scriptURL];
}

- (void)setParentInstance:(WXSDKInstance *)parentInstance
{
WXLogInfo(@"Embed instance %@ into parent instance %@", _instanceId, parentInstance.instanceId);
_parentInstance = parentInstance;
}

#pragma mark Public Mehtods

- (UIView *)rootView
Expand Down Expand Up @@ -710,12 +718,13 @@ - (void)_renderWithRequest:(WXResourceRequest *)request options:(NSDictionary *)
};

_mainBundleLoader.onFailed = ^(NSError *loadError) {
WXLogError(@"Request failed with error: %@", loadError);

NSString *errorMessage = [NSString stringWithFormat:@"Request to %@ occurs an error:%@, info:%@", request.URL, loadError.localizedDescription, loadError.userInfo];
long wxErrorCode = [loadError.domain isEqualToString:NSURLErrorDomain] && loadError.code == NSURLErrorNotConnectedToInternet ? WX_ERR_NOT_CONNECTED_TO_INTERNET : WX_ERR_JSBUNDLE_DOWNLOAD;

WX_MONITOR_FAIL_ON_PAGE(WXMTJSDownload, wxErrorCode, errorMessage, weakSelf.pageName);


NSMutableDictionary *allUserInfo = [[NSMutableDictionary alloc] initWithDictionary:error.userInfo];
[allUserInfo addEntriesFromDictionary:loadError.userInfo];
NSError *errorWithReportMsg = [NSError errorWithDomain:error.domain
Expand Down Expand Up @@ -766,6 +775,8 @@ - (void)refreshInstance:(id)data

- (void)destroyInstance
{
WXLogInfo(@"Destroy instance: %@", _instanceId);

[self.apmInstance endRecord];
NSString *url = @"";
if ([WXPrerenderManager isTaskExist:[self.scriptURL absoluteString]]) {
Expand Down Expand Up @@ -810,6 +821,7 @@ - (void)destroyInstance
// Reading config from orange for Release instance in Main Thread or not, for Bug #15172691 +{
dispatch_async(dispatch_get_main_queue(), ^{
[WXSDKManager removeInstanceforID:instanceId];
WXLogInfo(@"Finally remove instance: %@", instanceId);
});
//+}
});
Expand Down
1 change: 1 addition & 0 deletions ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.m
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ - (void) setStatistic:(NSString *)name withValue:(double)value
}

- (void)printRecordStageMap {
// These logs are for performance auto-test platforms.
__weak typeof(self) weakSelf = self;
WXPerformBlockOnComponentThread(^{
if (!weakSelf) {
Expand Down
1 change: 0 additions & 1 deletion weex_core/Source/core/bridge/script_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ class ScriptBridge {
inline ScriptSide *script_side() { return script_side_.get(); }

inline void set_core_side(CoreSide *core_side) {
LOGE("xxx set_core_side is runing and %p", core_side);
core_side_.reset(core_side);
core_side_->set_bridge(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
namespace WeexCore {

RenderActionCreateFinish::RenderActionCreateFinish(const std::string &page_id) {
LOGE("RenderActionCreateFinish::RenderActionCreateFinish");
this->page_id_ = page_id;
}

Expand Down
28 changes: 18 additions & 10 deletions weex_core/Source/core/render/manager/render_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ bool RenderManager::CreatePage(const std::string& page_id, const char *data) {
LOGD("[RenderManager] CreatePage >>>> pageId: %s, dom data: %s",
pageId.c_str(), parser.toStringUTF8().c_str());
#endif

LOGI("RenderManager::CreatePage, id: %s", page_id.c_str());

std::string targetName = RenderTargetManager::getRenderTargetName(page_id);
if (!targetName.empty()) {
Expand Down Expand Up @@ -95,6 +97,8 @@ bool RenderManager::CreatePage(const std::string& page_id, RenderObject *root) {
LOGD("[RenderManager] CreatePage >>>> pageId: %s, dom data: %s",
pageId.c_str(), parser.toStringUTF8().c_str());
#endif

LOGI("RenderManager::CreatePage, id: %s", page_id.c_str());

RenderPage *page = new RenderPage(page_id);
this->pages_.insert(std::pair<std::string, RenderPage *>(page_id, page));
Expand All @@ -108,23 +112,27 @@ bool RenderManager::CreatePage(const std::string& page_id, std::function<RenderO
#if RENDER_LOG
LOGD("[RenderManager] CreatePage >>>> pageId: %s", pageId.c_str());
#endif

LOGI("RenderManager::CreatePage, id: %s", page_id.c_str());

RenderPage *page = new RenderPage(page_id);
this->pages_.insert(std::pair<std::string, RenderPage *>(page_id, page));
RenderPage *page = new RenderPage(page_id);
this->pages_.insert(std::pair<std::string, RenderPage *>(page_id, page));

initDeviceConfig(page, page_id);
int64_t start_time = getCurrentTime();
RenderObject *root = constructRoot(page);
page->ParseJsonTime(getCurrentTime() - start_time);
return page->CreateRootRender(root);
initDeviceConfig(page, page_id);

int64_t start_time = getCurrentTime();
RenderObject *root = constructRoot(page);
page->ParseJsonTime(getCurrentTime() - start_time);

return page->CreateRootRender(root);
}

RenderPageCustom* RenderManager::CreateCustomPage(const std::string& page_id, const std::string& page_type) {
#if RENDER_LOG
LOGD("[RenderManager] CreateCustomPage >>>> pageId: %s, pageType: %s", pageId.c_str(), page_type.c_str());
#endif

LOGI("RenderManager::CreateCustomPage, id: %s, type: %s", page_id.c_str(), page_type.c_str());

RenderPageCustom::PageOptions options;

Expand Down Expand Up @@ -382,7 +390,7 @@ bool RenderManager::CreateFinish(const std::string &page_id) {
RenderPageBase *page = GetPage(page_id);
if (page == nullptr) return false;

LOGE("RenderManager::CreateFinish %s", page_id.data());
LOGI("RenderManager::CreateFinish, id: %s", page_id.data());

#if RENDER_LOG
LOGD("[RenderManager] CreateFinish >>>> pageId: %s", pageId.c_str());
Expand Down

0 comments on commit 4ce557b

Please sign in to comment.