[2.15.0] 整合基于ByteX开发的自研及三方插件

This commit is contained in:
renwj
2023-04-06 19:42:43 +08:00
parent a418616ae3
commit 695fd6188d
50 changed files with 184 additions and 347 deletions

View File

@@ -1,74 +0,0 @@
package com.mogo.eagle.core.function.chat.facade.aop
import android.os.Looper
import com.mogo.commons.debug.DebugConfig
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_CHAT
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import org.aspectj.lang.ProceedingJoinPoint
import org.aspectj.lang.reflect.CodeSignature
import org.aspectj.lang.reflect.MethodSignature
open class BaseAspectj {
companion object {
@Volatile
private var enable: Boolean = DebugConfig.isDebug()
}
fun enterMethod(joinPoint: ProceedingJoinPoint) {
if (!enable) return
val signature = joinPoint.signature as CodeSignature
val cls = signature.declaringType
val methodName = signature.name
val parameterNames = signature.parameterNames
val parameterValues = joinPoint.args
val builder = StringBuilder("\u21E2 ")
builder.append(methodName).append('(')
parameterValues.forEachIndexed { index, _ ->
if (index > 0) {
builder.append(",")
}
builder.append(parameterNames[index]).append('=')
builder.append(parameterValues[index])
}
builder.append(')')
if (Looper.myLooper() != Looper.getMainLooper()) {
builder.append("[Thread:\"").append(Thread.currentThread().name).append("\"]")
}
CallerLogger.d(M_CHAT + asTag(cls), builder.toString())
}
fun exitMethod(joinPoint: ProceedingJoinPoint, result: Any?, lengthMill: Long) {
if (!enable) return
val signature = joinPoint.signature
val cls = signature.declaringType
val methodName = signature.name
val hasReturnType = signature is MethodSignature
&& signature.returnType != Void.TYPE
val builder = StringBuilder("\u21E0 ")
.append(methodName)
.append("[")
.append(lengthMill)
.append("ms]")
if (hasReturnType) {
builder.append(" = ")
builder.append(result.let {
result.toString()
})
}
CallerLogger.d(M_CHAT + asTag(cls), builder.toString())
}
private fun asTag(cls: Class<*>): String {
if (cls.isAnonymousClass) {
return asTag(cls.enclosingClass!!)
}
return cls.simpleName
}
}

View File

@@ -1,5 +0,0 @@
package com.mogo.eagle.core.function.chat.facade.aop
@Target(AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.CONSTRUCTOR)
@kotlin.annotation.Retention(AnnotationRetention.RUNTIME)
annotation class DebugLog

View File

@@ -1,42 +0,0 @@
package com.mogo.eagle.core.function.chat.facade.aop
import org.aspectj.lang.ProceedingJoinPoint
import org.aspectj.lang.annotation.Around
import org.aspectj.lang.annotation.Aspect
import org.aspectj.lang.annotation.Pointcut
import java.util.concurrent.TimeUnit
@Aspect
class LogAspectj : BaseAspectj() {
@Pointcut("within(@com.mogo.eagle.core.function.chat.facade.aop.DebugLog *)")
fun withinAnnotatedClass() {
}
@Pointcut("execution(!synthetic * *(..))&& withinAnnotatedClass()")
fun methodInsideAnnotatedType() {
}
@Pointcut("execution(!synthetic *.new(..))&& withinAnnotatedClass()")
fun constructorInsideAnnotatedType() {
}
@Pointcut("execution(@com.mogo.eagle.core.function.chat.facade.aop.DebugLog * *(..))|| methodInsideAnnotatedType()")
fun method() {
}
@Pointcut("execution(@com.mogo.eagle.core.function.chat.facade.aop.DebugLog *.new(..))|| constructorInsideAnnotatedType()")
fun constructor() {
}
@Around("method() || constructor()")
fun logExecute(joinPoint: ProceedingJoinPoint) {
enterMethod(joinPoint)
val startNanos = System.nanoTime()
val result = joinPoint.proceed()
val stopNanos = System.nanoTime()
val lengthMill = TimeUnit.NANOSECONDS.toMillis(stopNanos - startNanos)
exitMethod(joinPoint, result, lengthMill)
}
}