Skip to content

Commit

Permalink
update(log-slf4j):兼容性还需修改
Browse files Browse the repository at this point in the history
  • Loading branch information
SakurajimaMaii committed Oct 16, 2024
1 parent dbbf1e9 commit cfce331
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 31 deletions.
2 changes: 2 additions & 0 deletions app-compose/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ android {
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
isCoreLibraryDesugaringEnabled = true
}

kotlinOptions {
Expand All @@ -93,6 +94,7 @@ android {

dependencies {
debugImplementation(libs.ui.test.manifest.compose)
coreLibraryDesugaring(libs.desugar.jdk.libs)
implementation(libs.activity.compose)
implementation(libs.adapter.rxjava3)
implementation(libs.coil.compose)
Expand Down
10 changes: 5 additions & 5 deletions app-compose/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<application
android:name=".ComposeApp"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:name=".ComposeApp"
android:theme="@style/Theme.AndroidVastExtension">

<activity
Expand All @@ -30,11 +30,11 @@
android:name=".ui.MainActivity"
android:exported="true"
android:theme="@style/Theme.AndroidVastExtension">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.MAIN" />-->

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
<!-- </intent-filter>-->
</activity>
<activity
android:name=".ui.LoggerActivity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.ave.vastgui.appcompose.ui

import android.os.Build
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
Expand All @@ -26,7 +27,7 @@ import org.slf4j.MarkerFactory
// Email: [email protected]
// Date: 2024/10/12

class LoggerActivity: ComponentActivity() {
class LoggerActivity : ComponentActivity() {

private val mLogger = LoggerFactory.getLogger("LoggerActivity")

Expand All @@ -44,16 +45,22 @@ class LoggerActivity: ComponentActivity() {

private fun dSimpleUsage() {
val marker = MarkerFactory.getMarker("Marker")
mLogger.debug(marker, HELLO_WORLD)
mLogger.debug(marker, HELLO_WORLD_FORMAT_1, HELLO_WORLD)
mLogger.debug(marker, HELLO_WORLD_FORMAT_2, HELLO_WORLD, HELLO_WORLD)
mLogger.debug(marker, HELLO_WORLD_FORMAT_MORE, HELLO_WORLD, HELLO_WORLD, HELLO_WORLD)
mLogger.debug(marker, HELLO_WORLD, Exception(HELLO_WORLD_EXCEPTION))
mLogger.debug(HELLO_WORLD)
mLogger.debug(HELLO_WORLD_FORMAT_1, HELLO_WORLD)
mLogger.debug(HELLO_WORLD_FORMAT_2, HELLO_WORLD, HELLO_WORLD)
mLogger.debug(HELLO_WORLD_FORMAT_MORE, HELLO_WORLD, HELLO_WORLD, HELLO_WORLD)
mLogger.debug(HELLO_WORLD, Exception(HELLO_WORLD_EXCEPTION))
if (false) {
mLogger.debug(marker, HELLO_WORLD)
mLogger.debug(marker, HELLO_WORLD_FORMAT_1, HELLO_WORLD)
mLogger.debug(marker, HELLO_WORLD_FORMAT_2, HELLO_WORLD, HELLO_WORLD)
mLogger.debug(marker, HELLO_WORLD_FORMAT_MORE, HELLO_WORLD, HELLO_WORLD, HELLO_WORLD)
mLogger.debug(marker, HELLO_WORLD, Exception(HELLO_WORLD_EXCEPTION))
mLogger.debug(HELLO_WORLD)
mLogger.debug(HELLO_WORLD_FORMAT_1, HELLO_WORLD)
mLogger.debug(HELLO_WORLD_FORMAT_2, HELLO_WORLD, HELLO_WORLD)
mLogger.debug(HELLO_WORLD_FORMAT_MORE, HELLO_WORLD, HELLO_WORLD, HELLO_WORLD)
mLogger.debug(HELLO_WORLD, Exception(HELLO_WORLD_EXCEPTION))
}
mLogger.atDebug().log {
Throwable().printStackTrace()
HELLO_WORLD
}
}

companion object {
Expand Down
3 changes: 3 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ core-ktx = "1.13.1"
core-runtime = "2.2.0"
core-splashscreen = "1.0.1"
datastore-preferences = "1.1.1"
desugar_jdk_libs = "2.1.2"
dialogx = "0.0.49"
dokka = "1.9.20"
espresso-core = "3.6.1"
Expand Down Expand Up @@ -59,6 +60,7 @@ ktor = "3.0.0-beta-2"
activity-compose = { module = "androidx.activity:activity-compose", version.ref = "activity-ktx" }
activity-ktx = { module = "androidx.activity:activity-ktx", version.ref = "activity-ktx" }
adapter-rxjava3 = { module = "com.squareup.retrofit2:adapter-rxjava3", version.ref = "converter-gson" }
androidx-core = { module = "androidx.core:core", version.ref = "core-ktx" }
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espresso-core" }
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "androidx-junit" }
androidx-navigation-fragment = { group = "androidx.navigation", name = "navigation-fragment", version.ref = "navigationFragment" }
Expand All @@ -76,6 +78,7 @@ core-ktx = { module = "androidx.core:core-ktx", version.ref = "core-ktx" }
core-runtime = { module = "androidx.arch.core:core-runtime", version.ref = "core-runtime" }
core-splashscreen = { module = "androidx.core:core-splashscreen", version.ref = "core-splashscreen" }
datastore-preferences = { module = "androidx.datastore:datastore-preferences", version.ref = "datastore-preferences" }
desugar_jdk_libs = { module = "com.android.tools:desugar_jdk_libs", version.ref = "desugar_jdk_libs" }
dialogx = { module = "com.kongzue.dialogx:DialogX", version.ref = "dialogx" }
dialogxiosstyle = { module = "com.kongzue.dialogx.style:DialogXIOSStyle", version.ref = "dialogx" }
dokka-base = { module = "org.jetbrains.dokka:dokka-base", version.ref = "dokka" }
Expand Down
4 changes: 2 additions & 2 deletions libraries/log/slf4j/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ plugins {
}

group = "io.github.sakurajimamaii"
version = "1.3.7"
version = "1.3.10"

java {
sourceCompatibility = JavaVersion.VERSION_17
Expand Down Expand Up @@ -70,7 +70,7 @@ if (mavenPropertiesFile.exists()) {
register<MavenPublication>("release") {
groupId = "io.github.sakurajimamaii"
artifactId = "log-slf4j"
version = "1.3.7"
version = "1.3.10"

afterEvaluate {
from(components["java"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,12 @@ import java.util.function.Supplier
// Author: Vast Gui
// Email: [email protected]
// Date: 2024/10/12
// Description:
// Documentation:
// Reference:
// Documentation: https://ave.entropy2020.cn/documents/log/log-slf4j/usage/

/**
* Slf4j event builder.
*
* @since 1.3.8
* @since 1.3.10
*/
internal class Slf4jEventBuilder(
private val logcat: LogCat,
Expand Down Expand Up @@ -91,7 +89,6 @@ internal class Slf4jEventBuilder(


override fun setMessage(messageSupplier: Supplier<String>?): LoggingEventBuilder = apply {
@Suppress("NewApi")
this.mMessage = messageSupplier?.get()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@ import java.util.concurrent.ConcurrentMap
* @since 1.3.7
*/
@LogExperimental
internal class Slf4jFactory(val logFactory: LogFactory) : ILoggerFactory {
internal class Slf4jFactory(private val logFactory: LogFactory) : ILoggerFactory {

/** @since 1.3.7 */
private val logcatMap: ConcurrentMap<String, Logger> = ConcurrentHashMap()

@Suppress("NewApi")
override fun getLogger(name: String): Logger {
return logcatMap.computeIfAbsent(name, this::createLogger)
val oldValue: Logger? = logcatMap[name]
if (null != oldValue) return oldValue
return createLogger(name).also { logcatMap.putIfAbsent(name, it) }
}

/** @since 1.3.7 */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ import org.slf4j.event.Level
// Author: Vast Gui
// Email: [email protected]
// Date: 2024/10/12
// Documentation: https://ave.entropy2020.cn/documents/log/log-slf4j/usage/

/**
* Convert [Level] to [LogLevel].
*
* @since 1.3.8
* @since 1.3.10
*/
fun convertLevel(level: Level?): LogLevel {
return when (level) {
Expand All @@ -43,7 +44,7 @@ fun convertLevel(level: Level?): LogLevel {
/**
* Convert [Marker] to [Marker.getName] or [default].
*
* @since 1.3.8
* @since 1.3.10
*/
fun convertMarker(marker: Marker?, default: String): String {
if (marker == null) return default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
import org.slf4j.Marker;
import org.slf4j.MarkerFactory;

import java.util.HashMap;
import java.util.function.Supplier;

public class SLF4JTest {

private static final String TAG = "SLF4JTest";
Expand Down

0 comments on commit cfce331

Please sign in to comment.