Skip to content

Commit ea2c3cf

Browse files
committed
Less verbose logging
1 parent cdd52c8 commit ea2c3cf

File tree

3 files changed

+31
-25
lines changed

3 files changed

+31
-25
lines changed

common/src/main/kotlin/com/lambda/config/Configuration.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import com.lambda.event.EventFlow.lambdaScope
99
import com.lambda.event.events.ClientEvent
1010
import com.lambda.event.listener.UnsafeListener.Companion.unsafeListener
1111
import com.lambda.module.ModuleConfig
12+
import com.lambda.util.StringUtils.capitalize
1213
import kotlinx.coroutines.Dispatchers
1314
import kotlinx.coroutines.launch
1415
import java.io.File
@@ -79,7 +80,7 @@ abstract class Configuration : Jsonable {
7980
private fun tryLoad() {
8081
lambdaScope.launch(Dispatchers.IO) {
8182
runCatching { load(primary) }
82-
.onSuccess { LOG.info("[IO] Config Manager: ${configName.replaceFirstChar(Char::titlecase) }} config loaded.") }
83+
.onSuccess { LOG.info("[IO] Config Manager: ${configName.capitalize()} config loaded.") }
8384
.onFailure {
8485
LOG.error("Failed to load $configName config, loading backup")
8586
runCatching { load(backup) }

common/src/main/kotlin/com/lambda/util/Communication.kt

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import com.lambda.Lambda.mc
55
import com.lambda.command.LambdaCommand
66
import com.lambda.module.Module
77
import com.lambda.threading.runSafe
8+
import com.lambda.util.StringUtils.capitalize
89
import com.lambda.util.text.*
910
import net.minecraft.client.toast.SystemToast
1011
import net.minecraft.text.Text
@@ -53,48 +54,50 @@ object Communication {
5354
}
5455
}
5556

56-
private fun Any.source(logLevel: LogLevel, color: Color = Color.GREY) = buildText {
57+
private fun Any.source(
58+
logLevel: LogLevel,
59+
color: Color = Color.GREY
60+
) = buildText {
5761
text(logLevel.prefix())
5862

59-
if (this@source is LambdaCommand) {
60-
styled(color, italic = true) {
61-
literal("Command ")
62-
}
63-
}
64-
65-
if (this@source is Module) {
66-
styled(color, italic = true) {
67-
literal("Module ")
68-
}
69-
}
70-
71-
// ToDo: HUD elements
72-
63+
// if (this@source is LambdaCommand) {
64+
// styled(color, italic = true) {
65+
// literal("Command ")
66+
// }
67+
// }
68+
//
69+
// if (this@source is Module) {
70+
// styled(color, italic = true) {
71+
// literal("Module ")
72+
// }
73+
// }
74+
//
75+
// // ToDo: HUD elements
76+
//
7377
if (this@source is Nameable) {
74-
styled(color, italic = true, underlined = true) {
75-
literal(name.replaceFirstChar(Char::titlecase))
78+
styled(color, italic = true) {
79+
literal("${name.capitalize()} ")
7680
}
7781
}
78-
79-
styled(color, italic = true) {
80-
literal(" \$ ")
81-
}
8282
}
8383

8484
private fun LogLevel.prefix() =
8585
buildText {
86-
literal(" ")
8786
styled(logoColor) {
8887
literal(Lambda.SYMBOL)
8988
}
9089
literal(" ")
9190
}
9291

93-
enum class LogLevel(val logoColor: Color, val messageColor: Color, val type: SystemToast.Type) {
92+
enum class LogLevel(
93+
val logoColor: Color,
94+
private val messageColor: Color,
95+
val type: SystemToast.Type
96+
) {
9497
DEBUG(Color.WHITE, Color.WHITE, SystemToast.Type.WORLD_BACKUP),
9598
INFO(Color.GREEN, Color.WHITE, SystemToast.Type.NARRATOR_TOGGLE),
9699
WARN(Color.YELLOW, Color.YELLOW, SystemToast.Type.WORLD_ACCESS_FAILURE),
97-
ERROR(Color.RED, Color.YELLOW, SystemToast.Type.WORLD_ACCESS_FAILURE);
100+
ERROR(Color.RED, Color.RED, SystemToast.Type.WORLD_ACCESS_FAILURE);
98101

99102
fun toast(title: Text, message: Text): SystemToast =
100103
SystemToast.create(mc, type, title, message)

common/src/main/kotlin/com/lambda/util/StringUtils.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.lambda.util
22

33
object StringUtils {
4+
fun String.capitalize() = replaceFirstChar { it.titlecase() }
5+
46
/**
57
* Find similar strings in a set of words.
68
*

0 commit comments

Comments
 (0)