Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
open-hippy authored Jan 22, 2024
2 parents 426072f + 8c13d04 commit e8ae1c1
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import com.tencent.mtt.hippy.common.Callback;
import com.tencent.mtt.hippy.common.HippyJsException;
import com.tencent.mtt.hippy.common.HippyMap;
import com.tencent.mtt.hippy.common.LogAdapter;
import com.tencent.mtt.hippy.common.ThreadExecutor;
import com.tencent.mtt.hippy.devsupport.DevServerCallBack;
import com.tencent.mtt.hippy.devsupport.DevSupportManager;
Expand Down Expand Up @@ -282,6 +283,11 @@ public FontAdapter getFontAdapter() {
return mEngineContext.getGlobalConfigs().getFontScaleAdapter();
}

@Override
public LogAdapter getLogAdapter() {
return mEngineContext.getGlobalConfigs().getLogAdapter();
}

@Override
public ImageDecoderAdapter getImageDecoderAdapter() {
return mEngineContext.getGlobalConfigs().getImageDecoderAdapter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,8 @@

package com.tencent.mtt.hippy.adapter;

import androidx.annotation.NonNull;
import com.tencent.mtt.hippy.common.LogAdapter;

public interface HippyLogAdapter {
public interface HippyLogAdapter extends LogAdapter {

int LOG_SEVERITY_DEBUG = -1;
int LOG_SEVERITY_INFO = 0;
int LOG_SEVERITY_WARNING = 1;
int LOG_SEVERITY_ERROR = 2;
int LOG_SEVERITY_FATAL = 3;

void onReceiveLogMessage(int level, @NonNull String tag, @NonNull String msg);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* Tencent is pleased to support the open source community by making Hippy available.
* Copyright (C) 2018 THL A29 Limited, a Tencent company. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.tencent.mtt.hippy.common;

import androidx.annotation.NonNull;

public interface LogAdapter {

int LOG_SEVERITY_DEBUG = -1;
int LOG_SEVERITY_INFO = 0;
int LOG_SEVERITY_WARNING = 1;
int LOG_SEVERITY_ERROR = 2;
int LOG_SEVERITY_FATAL = 3;

void onReceiveLogMessage(int level, @NonNull String tag, @NonNull String msg);
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.tencent.mtt.hippy.common.LogAdapter;
import com.tencent.renderer.component.image.ImageDecoderAdapter;
import com.tencent.renderer.component.text.FontAdapter;
import com.tencent.vfs.VfsManager;
Expand All @@ -31,6 +32,9 @@ public interface FrameworkProxy {
@Nullable
FontAdapter getFontAdapter();

@Nullable
LogAdapter getLogAdapter();

@NonNull
VfsManager getVfsManager();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import androidx.annotation.Nullable;

import com.tencent.mtt.hippy.HippyInstanceLifecycleEventListener;
import com.tencent.mtt.hippy.common.LogAdapter;
import com.tencent.mtt.hippy.uimanager.RenderManager;

import com.tencent.renderer.component.image.ImageDecoderAdapter;
Expand All @@ -35,7 +36,7 @@
import java.util.Map;
import java.util.concurrent.Executor;

public interface NativeRender extends RenderExceptionHandler {
public interface NativeRender extends RenderExceptionHandler, RenderLogHandler {

@NonNull
RenderManager getRenderManager();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import java.util.List;

public interface NativeRenderDelegate extends RenderExceptionHandler {
public interface NativeRenderDelegate extends RenderExceptionHandler, RenderLogHandler {

void createNode(int rootId, @NonNull List<Object> nodeList) throws NativeRenderException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import androidx.annotation.Nullable;

import com.tencent.mtt.hippy.common.Callback;
import com.tencent.mtt.hippy.common.LogAdapter;
import com.tencent.mtt.hippy.serialization.nio.reader.BinaryReader;
import com.tencent.mtt.hippy.serialization.nio.reader.SafeHeapReader;
import com.tencent.mtt.hippy.serialization.nio.writer.SafeHeapWriter;
Expand Down Expand Up @@ -222,6 +223,11 @@ public FontAdapter getFontAdapter() {
return (mFrameworkProxy != null) ? mFrameworkProxy.getFontAdapter() : null;
}

@Nullable
public LogAdapter getLogAdapter() {
return (mFrameworkProxy != null) ? mFrameworkProxy.getLogAdapter() : null;
}

@Override
@Nullable
public Executor getBackgroundExecutor() {
Expand Down Expand Up @@ -257,6 +263,14 @@ public void handleRenderException(@NonNull Exception exception) {
}
}

@Override
public void onReceiveRenderLogMessage(int level, @NonNull String tag, @NonNull String msg) {
LogAdapter logAdapter = getLogAdapter();
if (logAdapter != null) {
logAdapter.onReceiveLogMessage(level, tag, msg);
}
}

@Override
public int getEngineId() {
if (mFrameworkProxy != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* Tencent is pleased to support the open source community by making Hippy available.
* Copyright (C) 2018 THL A29 Limited, a Tencent company. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.tencent.renderer;

import androidx.annotation.NonNull;
import com.tencent.mtt.hippy.common.LogAdapter;

public interface RenderLogHandler {
/**
* Output render log to host
*
* @param level {@link LogAdapter} the render log level
* @param tag the render log tag
* @param msg the render log message
*/
void onReceiveRenderLogMessage(int level, @NonNull String tag, @NonNull String msg);
}

0 comments on commit e8ae1c1

Please sign in to comment.