Skip to content

Commit

Permalink
调整日志输出逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
biezhihua committed Sep 24, 2024
1 parent a22d1b2 commit eb2f714
Show file tree
Hide file tree
Showing 41 changed files with 294 additions and 388 deletions.
33 changes: 17 additions & 16 deletions GaiaXAndroid/src/main/kotlin/com/alibaba/gaiax/GXTemplateEngine.kt
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ class GXTemplateEngine {
*/
class GXScroll {
companion object {

const val TYPE_ON_SCROLL_STATE_CHANGED = "onScrollStateChanged"
const val TYPE_ON_SCROLLED = "onScrolled"
}
Expand Down Expand Up @@ -506,7 +507,7 @@ class GXTemplateEngine {
gxMeasureSize: GXMeasureSize,
gxVisualTemplateNode: GXTemplateNode? = null
) {
Log.runE { "GXTemplateEngine.prepareView" }
Log.runE(TAG) { "prepareView" }
try {
if (GXGlobalCache.instance.isExistForPrepareView(gxMeasureSize, gxTemplateItem)) {
return
Expand Down Expand Up @@ -551,7 +552,7 @@ class GXTemplateEngine {
gxMeasureSize: GXMeasureSize,
gxExtendParams: GXExtendParams? = null
): View? {
Log.runE { "GXTemplateEngine.createView" }
Log.runE(TAG) { "createView" }
return try {
prepareView(gxTemplateItem, gxMeasureSize)

Expand Down Expand Up @@ -582,7 +583,7 @@ class GXTemplateEngine {
* @throws IllegalArgumentException
*/
fun bindData(gxView: View?, gxTemplateData: GXTemplateData, gxMeasureSize: GXMeasureSize? = null) {
Log.runE { "GXTemplateEngine.bindData" }
Log.runE(TAG) { "bindData" }
try {
if (gxView == null) {
throw IllegalArgumentException("view is null")
Expand All @@ -601,7 +602,7 @@ class GXTemplateEngine {
}

fun resetView(gxView: View) {
Log.runE { "GXTemplateEngine.resetView" }
Log.runE(TAG) { "resetView" }
try {
GXTemplateContext.getContext(gxView)?.let { gxTemplateContext ->
render.resetViewDataOnlyViewTree(gxTemplateContext)
Expand All @@ -627,7 +628,7 @@ class GXTemplateEngine {
val gxRootNode = gxTemplateContext.rootNode
if (gxRootNode != null) {

Log.runE { "GXTemplateEngine.recomputeWhenMeasureSizeChanged traceId=${gxTemplateContext.traceId}" }
Log.runE(TAG) { "recomputeWhenMeasureSizeChanged traceId=${gxTemplateContext.traceId}" }

val size = Size(gxTemplateContext.size.width, gxTemplateContext.size.height)
GXNodeUtils.computeNodeTreeByPrepareView(gxTemplateContext, gxRootNode, size)
Expand All @@ -647,7 +648,7 @@ class GXTemplateEngine {
gxMeasureSize: GXMeasureSize,
gxExtendParams: GXExtendParams? = null
): GXTemplateContext? {
Log.runE { "GXTemplateEngine.createViewOnlyNodeTree" }
Log.runE(TAG) { "createViewOnlyNodeTree" }
return try {
if (GXPropUtils.isTrace() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
Trace.beginSection("GX createViewOnlyNodeTree")
Expand Down Expand Up @@ -698,7 +699,7 @@ class GXTemplateEngine {
* @hide
*/
fun createViewOnlyViewTree(gxTemplateContext: GXTemplateContext): View? {
Log.runE { "GXTemplateEngine.createViewOnlyViewTree" }
Log.runE(TAG) { "createViewOnlyViewTree" }
return try {
if (GXPropUtils.isTrace()) {
Trace.beginSection("GX createViewOnlyViewTree")
Expand Down Expand Up @@ -727,7 +728,7 @@ class GXTemplateEngine {
* @hide
*/
fun bindDataOnlyNodeTree(view: View, gxTemplateData: GXTemplateData, gxMeasureSize: GXMeasureSize? = null) {
Log.runE { "GXTemplateEngine.bindDataOnlyNodeTree" }
Log.runE(TAG) { "bindDataOnlyNodeTree" }
try {
if (GXPropUtils.isTrace()) {
Trace.beginSection("GX bindDataOnlyNodeTree")
Expand All @@ -750,20 +751,20 @@ class GXTemplateEngine {
?: throw IllegalArgumentException("Not found templateContext from targetView")

if (gxTemplateContext.isReuseRootNode) {
Log.runE { "GXTemplateEngine.internalBindDataOnlyNodeTree reuse root node, skip bindDataOnlyNodeTree traceId=${gxTemplateContext.traceId}" }
Log.runE(TAG) { "internalBindDataOnlyNodeTree reuse root node, skip bindDataOnlyNodeTree traceId=${gxTemplateContext.traceId}" }
gxTemplateContext.isReuseRootNode = false
return
}

Log.runE { "GXTemplateEngine.internalBindDataOnlyNodeTree traceId=${gxTemplateContext.traceId} gxMeasureSize=${gxTemplateContext.size} gxTemplateItem=${gxTemplateContext.templateItem} gxMeasureSize=${gxMeasureSize} " }
Log.runE(TAG) { "internalBindDataOnlyNodeTree traceId=${gxTemplateContext.traceId} gxMeasureSize=${gxTemplateContext.size} gxTemplateItem=${gxTemplateContext.templateItem} gxMeasureSize=${gxMeasureSize} " }

gxTemplateContext.templateData = gxTemplateData

if (gxMeasureSize != null) {
val oldMeasureSize = gxTemplateContext.size
gxTemplateContext.size = gxMeasureSize

Log.runE { "GXTemplateEngine.internalBindDataOnlyNodeTree traceId=${gxTemplateContext.traceId} gxMeasureSize update ${gxTemplateContext.size}" }
Log.runE(TAG) { "internalBindDataOnlyNodeTree traceId=${gxTemplateContext.traceId} gxMeasureSize update ${gxTemplateContext.size}" }

// 判断是否size发生了变化
gxTemplateContext.isMeasureSizeChanged = oldMeasureSize.width != gxMeasureSize.width || oldMeasureSize.height != gxMeasureSize.height
Expand All @@ -785,7 +786,7 @@ class GXTemplateEngine {
* @hide
*/
fun bindDataOnlyViewTree(view: View, gxTemplateData: GXTemplateData, gxMeasureSize: GXMeasureSize? = null) {
Log.runE { "GXTemplateEngine.bindDataOnlyViewTree" }
Log.runE(TAG) { "bindDataOnlyViewTree" }
try {
if (GXPropUtils.isTrace()) {
Trace.beginSection("GX bindDataOnlyViewTree")
Expand All @@ -809,7 +810,7 @@ class GXTemplateEngine {

if (gxMeasureSize != null) {
gxTemplateContext.size = gxMeasureSize
Log.runE { "GXTemplateEngine.internalBindDataOnlyViewTree traceId=${gxTemplateContext.traceId} gxMeasureSize=${gxTemplateContext.size} gxTemplateItem=${gxTemplateContext.templateItem} gxMeasureSize=${gxMeasureSize} " }
Log.runE(TAG) { "internalBindDataOnlyViewTree traceId=${gxTemplateContext.traceId} gxMeasureSize=${gxTemplateContext.size} gxTemplateItem=${gxTemplateContext.templateItem} gxMeasureSize=${gxMeasureSize} " }
}

gxTemplateContext.templateData = gxTemplateData
Expand Down Expand Up @@ -856,7 +857,7 @@ class GXTemplateEngine {
* 通知视图可见,如果视图是容器,那么也通知其坑位视图可见
*/
fun onAppear(targetView: View?) {
Log.runE { "GXTemplateEngine.onAppear" }
Log.runE(TAG) { "onAppear" }
GXTemplateContext.getContext(targetView)?.let { gxTemplateContext ->
gxTemplateContext.isAppear = true
gxTemplateContext.manualExposure()
Expand All @@ -868,7 +869,7 @@ class GXTemplateEngine {
* 通知视图不可见,如果视图是容器,那么也通知其坑位视图不可见
*/
fun onDisappear(targetView: View?) {
Log.runE { "GXTemplateEngine.onDisappear" }
Log.runE(TAG) { "onDisappear" }
GXTemplateContext.getContext(targetView)?.let { gxTemplateContext ->
gxTemplateContext.isAppear = false
GXContainerUtils.notifyContainerAndItemsOnDisappear(gxTemplateContext)
Expand Down Expand Up @@ -911,7 +912,7 @@ class GXTemplateEngine {
}

companion object {

private const val TAG = "GXTemplateEngine"
val instance by lazy {
GXTemplateEngine()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package com.alibaba.gaiax.context

import app.visly.stretch.Layout
import com.alibaba.gaiax.render.node.GXNode
import com.alibaba.gaiax.utils.Log
import com.alibaba.gaiax.utils.runE

fun GXTemplateContext.initLayoutForScroll() {
if (scrollItemLayoutCache == null) {
Expand All @@ -20,9 +22,7 @@ fun GXTemplateContext.isExistForScroll(key: Any): Boolean {
}

fun GXTemplateContext.putLayoutForScroll(key: Any, value: Layout) {
if (Log.isLog()) {
Log.e("putLayoutForScroll key=$key value=$value")
}
Log.runE("GXTemplateContextExt") { "putLayoutForScroll key=$key value=$value" }
scrollItemLayoutCache?.put(key, value)
}

Expand Down Expand Up @@ -56,15 +56,11 @@ fun GXTemplateContext.isExistNodeForScroll(key: Any): Boolean {

fun GXTemplateContext.obtainNodeForScroll(key: Any): GXNode? {
val value = scrollNodeCache?.remove(key)
if (Log.isLog()) {
Log.e("obtainNodeForScroll key=${key} value=${value}")
}
Log.runE("GXTemplateContextExt") { "obtainNodeForScroll key=$key value=$value" }
return value
}

fun GXTemplateContext.putNodeForScroll(key: Any, value: GXNode) {
scrollNodeCache?.put(key, value)
if (Log.isLog()) {
Log.e("putNodeForScroll key=${key} value=${value}")
}
Log.runE("GXTemplateContextExt") { "putNodeForScroll key=$key value=$value" }
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,18 @@ import com.alibaba.gaiax.render.view.GXIRootView
import com.alibaba.gaiax.render.view.GXViewTreeCreator
import com.alibaba.gaiax.render.view.GXViewTreeUpdate
import com.alibaba.gaiax.utils.GXGlobalCache
import com.alibaba.gaiax.utils.Log
import com.alibaba.gaiax.utils.runE

/**
* @suppress
*/
class GXRenderImpl {

companion object {
private const val TAG = "GXRenderImpl"
}


fun prepareView(gxTemplateContext: GXTemplateContext) {
val rootNode = GXNodeTreePrepare.create(gxTemplateContext)
Expand All @@ -46,9 +52,7 @@ class GXRenderImpl {
val rootLayout = GXGlobalCache.instance.getLayoutForPrepareView(gxTemplateContext, gxTemplateContext.templateItem)
?: throw IllegalArgumentException("root layout is null")

if (Log.isLog()) {
Log.e(gxTemplateContext.tag, "traceId=${gxTemplateContext.traceId} tag=createViewOnlyNodeTree rootLayout=${rootLayout}")
}
Log.runE(TAG) { "createViewOnlyNodeTree traceId=${gxTemplateContext.traceId}"}

// Create a virtual node tree
val rootNode = GXNodeTreeCreator.create(gxTemplateContext, rootLayout)
Expand All @@ -71,9 +75,7 @@ class GXRenderImpl {
}

fun bindViewDataOnlyNodeTree(gxTemplateContext: GXTemplateContext) {
if (Log.isLog()) {
Log.e(gxTemplateContext.tag, "traceId=${gxTemplateContext.traceId} tag=bindViewDataOnlyNodeTree")
}
Log.runE(TAG) { "bindViewDataOnlyNodeTree traceId=${gxTemplateContext.traceId}"}

// Resetting the Template Status
gxTemplateContext.isDirty = false
Expand All @@ -83,9 +85,7 @@ class GXRenderImpl {
}

fun bindViewDataOnlyViewTree(gxTemplateContext: GXTemplateContext) {
if (Log.isLog()) {
Log.e(gxTemplateContext.tag, "traceId=${gxTemplateContext.traceId} tag=bindViewDataOnlyViewTree")
}
Log.runE(TAG) { "bindViewDataOnlyViewTree traceId=${gxTemplateContext.traceId}"}

val rootNode = gxTemplateContext.rootNode
?: throw IllegalArgumentException("RootNode is null(bindViewDataOnlyViewTree) gxTemplateContext = $gxTemplateContext")
Expand All @@ -98,10 +98,7 @@ class GXRenderImpl {
}

fun resetViewDataOnlyViewTree(gxTemplateContext: GXTemplateContext) {
if (Log.isLog()) {
Log.e(gxTemplateContext.tag, "traceId=${gxTemplateContext.traceId} tag=resetViewDataOnlyViewTree")
}

Log.runE(TAG) { "resetViewDataOnlyViewTree traceId=${gxTemplateContext.traceId}"}
GXNodeTreeUpdate.resetView(gxTemplateContext)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,17 @@ import com.alibaba.gaiax.template.animation.GXLottieAnimation
import com.alibaba.gaiax.template.animation.GXPropAnimationSet
import com.alibaba.gaiax.template.factory.GXExpressionFactory
import com.alibaba.gaiax.template.utils.GXTemplateUtils
import com.alibaba.gaiax.utils.Log
import com.alibaba.gaiax.utils.runE

/**
* @suppress
*/
object GXNodeTreeUpdate {
private const val TAG = "GXNodeTreeUpdate"

fun buildNodeLayout(gxTemplateContext: GXTemplateContext) {
if (Log.isLog()) {
Log.e(gxTemplateContext.tag, "traceId=${gxTemplateContext.traceId} tag=buildNodeLayout")
}
Log.runE(TAG) { "buildNodeLayout traceId=${gxTemplateContext.traceId}" }

val rootNode = gxTemplateContext.rootNode
?: throw IllegalArgumentException("RootNode is null(buildNodeLayout)")
Expand Down Expand Up @@ -109,16 +110,15 @@ object GXNodeTreeUpdate {
}

object Layout {
private const val TAG = "Layout"

internal fun updateNodeTreeLayout(
gxTemplateContext: GXTemplateContext,
gxNode: GXNode,
templateData: JSONObject,
size: Size<Float?>
) {
if (Log.isLog()) {
Log.e(gxTemplateContext.tag, "traceId=${gxTemplateContext.traceId} tag=updateNodeTreeLayout")
}
Log.runE(TAG) { "updateNodeTreeLayout traceId=${gxTemplateContext.traceId}" }

// 更新布局
updateNodeTreeLayout(gxTemplateContext, gxNode, templateData)
Expand All @@ -132,9 +132,7 @@ object GXNodeTreeUpdate {
internal fun updateNodeTreeLayoutByDirtyText(gxTemplateContext: GXTemplateContext, rootNode: GXNode, size: Size<Float?>) {
if (gxTemplateContext.dirtyTexts?.isNotEmpty() == true) {

if (Log.isLog()) {
Log.e(gxTemplateContext.tag, "traceId=${gxTemplateContext.traceId} tag=updateNodeTreeLayoutByDirtyText")
}
Log.runE(TAG) { "updateNodeTreeLayoutByDirtyText traceId=${gxTemplateContext.traceId}" }

var isTextDirty = false
gxTemplateContext.dirtyTexts?.forEach {
Expand Down Expand Up @@ -331,9 +329,7 @@ object GXNodeTreeUpdate {
isDirty = true
}

if (Log.isLog()) {
Log.e(gxTemplateContext.tag, "traceId=${gxTemplateContext.traceId} tag=updateContainerLayout containerSize=${containerSize}")
}
Log.runE(TAG) { "updateContainerLayout traceId=${gxTemplateContext.traceId} containerSize=${containerSize}" }
}

} else if (gxNode.isGridType()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ import com.alibaba.gaiax.context.putNodeForScroll
import com.alibaba.gaiax.template.GXGridConfig
import com.alibaba.gaiax.template.GXTemplateKey
import com.alibaba.gaiax.utils.GXGlobalCache
import com.alibaba.gaiax.utils.Log
import com.alibaba.gaiax.utils.getStringExt
import com.alibaba.gaiax.utils.runE
import kotlin.math.ceil
import kotlin.math.max

Expand All @@ -44,6 +46,8 @@ import kotlin.math.max
*/
object GXNodeUtils {

private const val TAG = "GXNodeUtils"

internal const val ITEM_PATH = "${GXTemplateKey.GAIAX_DATABINDING_ITEM_TYPE}.${GXTemplateKey.GAIAX_DATABINDING_ITEM_TYPE_PATH}"
internal const val ITEM_CONFIG = "${GXTemplateKey.GAIAX_DATABINDING_ITEM_TYPE}.${GXTemplateKey.GAIAX_DATABINDING_ITEM_TYPE_CONFIG}"

Expand All @@ -54,14 +58,7 @@ object GXNodeUtils {
) {

// 预处理布局
if (Log.isLog()) {
Log.e(gxTemplateContext.tag, "traceId=${gxTemplateContext.traceId} tag=computeNodeTreeByBindData layoutByPrepare=${gxNode.layoutByPrepare}")
}

// 输入参数
if (Log.isLog()) {
Log.e(gxTemplateContext.tag, "traceId=${gxTemplateContext.traceId} tag=computeNodeTreeByBindData gxNode=${gxNode}")
}
Log.runE(TAG) { "computeNodeTreeByBindData traceId=${gxTemplateContext.traceId} layoutByPrepare=${gxNode.layoutByPrepare} gxNode=${gxNode}" }

val stretchNode = gxNode.stretchNode.node
?: throw IllegalArgumentException("stretch node is null, please check!")
Expand All @@ -71,9 +68,7 @@ object GXNodeUtils {
composeStretchNodeByBindData(gxNode, layout)

// 输出计算结果
if (Log.isLog()) {
Log.e(gxTemplateContext.tag, "traceId=${gxTemplateContext.traceId} tag=computeNodeTreeByBindData layoutByBind=${gxNode.layoutByBind}")
}
Log.runE(TAG) { "computeNodeTreeByBindData traceId=${gxTemplateContext.traceId} layoutByBind=${gxNode.layoutByBind}" }
}

private fun composeStretchNodeByBindData(gxNode: GXNode, layout: Layout) {
Expand All @@ -95,9 +90,7 @@ object GXNodeUtils {
?: throw IllegalArgumentException("stretch node is null, please check!")
val layout = stretchNode.safeComputeLayout(size)
composeStretchNodeByPrepareView(gxNode, layout)
if (Log.isLog()) {
Log.e(gxTemplateContext.tag, "traceId=${gxTemplateContext.traceId} tag=computeNodeTreeByPrepareView layout=${layout}")
}
Log.runE(TAG) { "computeNodeTreeByPrepareView traceId=${gxTemplateContext.traceId} layoutByPrepare=${gxNode.layoutByPrepare} gxNode=${gxNode}" }
}

private fun composeStretchNodeByPrepareView(gxNode: GXNode, layout: Layout) {
Expand Down
Loading

0 comments on commit eb2f714

Please sign in to comment.