mirror of
https://github.com/dalbodeule/chibot-chzzk-bot.git
synced 2025-08-07 04:41:13 +00:00
[feature] add loki handler.
This commit is contained in:
@@ -29,6 +29,7 @@ repositories {
|
||||
dependencies {
|
||||
// https://mvnrepository.com/artifact/ch.qos.logback/logback-classic
|
||||
implementation("ch.qos.logback:logback-classic:1.5.13")
|
||||
implementation("com.github.loki4j:loki-logback-appender:2.0.0")
|
||||
|
||||
// https://mvnrepository.com/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0")
|
||||
|
@@ -204,6 +204,7 @@ class UserHandler(
|
||||
val logger: Logger,
|
||||
private var user: User,
|
||||
var streamStartTime: LocalDateTime?,
|
||||
val chatLogger: Logger = LoggerFactory.getLogger("${channel.channelName}-chat"),
|
||||
) {
|
||||
lateinit var client: ChzzkClient
|
||||
lateinit var chatChannelId: String
|
||||
@@ -370,6 +371,7 @@ class UserHandler(
|
||||
GlobalScope.launch {
|
||||
delay(100L)
|
||||
client.sendChatToLoggedInChannel(msg.limitUtf8Length(100))
|
||||
chatLogger.info("[SEND]${channel.channelName}: ${msg.limitUtf8Length(100)}{${msg.length} / 100}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -31,6 +31,7 @@ class MessageHandler(
|
||||
|
||||
private val channel = handler.channel
|
||||
private val logger = handler.logger
|
||||
private val chatLogger = handler.chatLogger
|
||||
private val listener = handler.listener
|
||||
|
||||
private val dispatcher: CoroutinesEventBus by inject(CoroutinesEventBus::class.java)
|
||||
@@ -372,7 +373,7 @@ class MessageHandler(
|
||||
|
||||
internal fun handle(msg: SessionChatMessage, user: User) {
|
||||
if(msg.senderChannelId == ChzzkHandler.botUid) return
|
||||
|
||||
chatLogger.info("[RECV]${channel.channelName}: ${msg.content}{${msg.content.length} / 100}")
|
||||
val commandKey = msg.content.split(' ')[0]
|
||||
commands[commandKey.lowercase()]?.let { it(msg, user) }
|
||||
}
|
||||
|
@@ -10,6 +10,13 @@
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<appender name="LOKI" class="com.github.loki4j.logback.Loki4jAppender">
|
||||
<labels>
|
||||
app = chibot-chzzk-bot
|
||||
host = ${LOKI_ENDPOINT:http://localhost:3100/loki/api/v1/push}
|
||||
</labels>
|
||||
</appender>
|
||||
|
||||
<!-- HikariCP 로그 레벨 설정 -->
|
||||
<logger name="com.zaxxer.hikari" level="INFO" />
|
||||
<logger name="o.m.jdbc.client.impl.StandardClient" level="INFO" />
|
||||
@@ -31,5 +38,8 @@
|
||||
<root level="DEBUG">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
<root level="INFO">
|
||||
<appender-ref ref="LOKI" />
|
||||
</root>
|
||||
|
||||
</configuration>
|
Reference in New Issue
Block a user