Skip to content

Commit

Permalink
version(log-core):1.3.8 版本现已发布
Browse files Browse the repository at this point in the history
  • Loading branch information
SakurajimaMaii committed Oct 15, 2024
1 parent c74f26e commit d6a41d2
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 19 deletions.
6 changes: 3 additions & 3 deletions libraries/log/core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ plugins {
}

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

java {
sourceCompatibility = JavaVersion.VERSION_17
Expand All @@ -48,9 +48,9 @@ kotlin.sourceSets.all {
}

dependencies {
compileOnly(libs.fastjson2)
compileOnly(libs.gson)
compileOnly(libs.jackson.databind)
implementation(libs.fastjson2)
implementation(projects.libraries.kernel)
testImplementation(libs.fastjson2)
testImplementation(libs.gson)
Expand All @@ -70,7 +70,7 @@ if (mavenPropertiesFile.exists()) {
register<MavenPublication>("release") {
groupId = "io.github.sakurajimamaii"
artifactId = "log-core"
version = "1.3.7"
version = "1.3.8"

afterEvaluate {
from(components["java"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import kotlin.properties.Delegates
*/
class LogJson private constructor(mConfiguration: Configuration) {

private val converter: Converter = mConfiguration.converter
private val mConverter: Converter = mConfiguration.converter

/**
* Configuration of [LogJson].
Expand All @@ -58,7 +58,7 @@ class LogJson private constructor(mConfiguration: Configuration) {
}

/** @since 1.3.8 */
private fun toJson(data: Any): String = converter.toJson(data)
private fun toJson(data: Any): String = mConverter.toJson(data)

companion object : LogPlugin<Configuration, LogJson> {

Expand All @@ -67,7 +67,6 @@ class LogJson private constructor(mConfiguration: Configuration) {
override fun install(plugin: LogJson, scope: LogCat) {
scope.logPipeline.intercept(LogPipeline.Transform) {
val content = subject.content()
// already string, skip
if (content is String) {
proceed()
return@intercept
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,17 @@ import kotlin.properties.Delegates
*
* @since 1.3.4
*/
class LogPretty private constructor(private val mConfiguration: Configuration) {
class LogPretty private constructor(mConfiguration: Configuration) {

private val mConverter: Converter = mConfiguration.converter

class Configuration internal constructor() {
var converter: Converter by Delegates.notNull()
}

/** @since 1.3.8 */
private fun parseString(json: String): Any = mConverter.parseString(json)

companion object : LogPlugin<Configuration, LogPretty> {

override val key: String = LogPretty::class.java.simpleName
Expand All @@ -59,8 +64,7 @@ class LogPretty private constructor(private val mConfiguration: Configuration) {
val rawContent = subject.getStringContent()
// Try to render the log content and return the
// original content if an exception occurs.
val content = plugin.mConfiguration
.converter.parseString(rawContent)
val content = plugin.parseString(rawContent)
subject.setStringContent(content.toString())
proceedWith(subject)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ val logFactory: LogFactory = getLogFactory {
}
install(LogPrinter) {
levelSet = allLogLevel
logger = SimpleLogger(TableFormat(1000, Int.MAX_VALUE, TableFormat.LogHeader.default))
logger = SimpleLogger(TableFormat(1000, 20, ellipsis = "******"))
//logger = SimpleLogger(LineFormat)
}
install(LogJson) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,6 @@ private val objs = arrayOf(
user, address1, userProfile, comment1, post
)

private val paragraph = """
苏州园林里都有假山和池沼。假山的堆叠,可以说是一项艺术而不仅是技术。或者是重峦叠嶂,或者是几座小山配合着竹子花木,
全在乎设计者和匠师们生平多阅历,胸中有邱壑,才能使游览者攀登的时候忘却苏州城市,只觉得身在山间。至于池沼,大多引
用活水。有些园林池沼宽敞,就把池沼作为全园的中心,其他景物配合着布置。水面假如成河道模样,往往安排桥梁。假如安排
两座以上的桥梁,那就一座一个样,决不雷同。池沼或河道的边沿很少砌齐整的石岸,总是高低屈曲任其自然。还在那儿布置几
块玲珑的石头,或者种些花草:这也是为了取得从各个角度看都成一幅画的效果。池沼里养着金鱼或各色鲤鱼,夏秋季节荷花或
睡莲开放,游览者看“鱼戏莲叶间”,又是入画的一景。
""".trimIndent()

class SimpleKtTest {

private val logcat = logFactory("tag")
Expand Down Expand Up @@ -241,6 +232,19 @@ class SimpleKtTest {
logcat.d(json)
}

@Test
fun paragraph() {
val paragraph = """
苏州园林里都有假山和池沼。假山的堆叠,可以说是一项艺术而不仅是技术。或者是重峦叠嶂,或者是几座小山配合着竹子花木,
全在乎设计者和匠师们生平多阅历,胸中有邱壑,才能使游览者攀登的时候忘却苏州城市,只觉得身在山间。至于池沼,大多引
用活水。有些园林池沼宽敞,就把池沼作为全园的中心,其他景物配合着布置。水面假如成河道模样,往往安排桥梁。假如安排
两座以上的桥梁,那就一座一个样,决不雷同。池沼或河道的边沿很少砌齐整的石岸,总是高低屈曲任其自然。还在那儿布置几
块玲珑的石头,或者种些花草:这也是为了取得从各个角度看都成一幅画的效果。池沼里养着金鱼或各色鲤鱼,夏秋季节荷花或
睡莲开放,游览者看“鱼戏莲叶间”,又是入画的一景。
""".trimIndent()
logcat.d(paragraph)
}

@OptIn(LogExperimental::class)
@Test
fun nullUsage() {
Expand Down

0 comments on commit d6a41d2

Please sign in to comment.