diff options
| author | Sho Sakuma <me@m1sk9.dev> | 2026-01-31 17:50:11 +0900 |
|---|---|---|
| committer | Sho Sakuma <me@m1sk9.dev> | 2026-01-31 17:50:17 +0900 |
| commit | cdb03c1e628004820b0d2b70682f52f4f97c4663 (patch) | |
| tree | 2b2e9b9e89bde694c913b06d3c59b9a169f2f68e /engine/src | |
| parent | ec963f344264edfca80c8e1487206997fc1033ff (diff) | |
| download | LunaticChat-cdb03c1e628004820b0d2b70682f52f4f97c4663.tar.gz LunaticChat-cdb03c1e628004820b0d2b70682f52f4f97c4663.tar.bz2 LunaticChat-cdb03c1e628004820b0d2b70682f52f4f97c4663.zip | |
feat: Add channel logging
Diffstat (limited to 'engine/src')
| -rw-r--r-- | engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/chat/channel/ChannelMessageLogEntry.kt | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/chat/channel/ChannelMessageLogEntry.kt b/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/chat/channel/ChannelMessageLogEntry.kt new file mode 100644 index 0000000..7cd4eb6 --- /dev/null +++ b/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/chat/channel/ChannelMessageLogEntry.kt @@ -0,0 +1,51 @@ +package dev.m1sk9.lunaticChat.engine.chat.channel + +import kotlinx.serialization.Serializable +import java.time.Instant +import java.util.UUID + +/** + * Represents a single channel message log entry in NDJSON format. + * + * This data class is designed for append-only logging to daily rotated files, + * compatible with Grafana Loki and other log aggregation systems. + * + * @property timestamp ISO-8601 formatted UTC timestamp of when the message was sent + * @property playerId UUID of the player who sent the message + * @property playerName Display name of the player + * @property channelId Unique identifier of the channel + * @property message The chat message content + */ +@Serializable +data class ChannelMessageLogEntry( + val timestamp: String, + val playerId: String, + val playerName: String, + val channelId: String, + val message: String, +) { + companion object { + /** + * Creates a new log entry with the current timestamp. + * + * @param playerId UUID of the player + * @param playerName Display name of the player + * @param channelId Channel identifier + * @param message Message content + * @return New ChannelMessageLogEntry instance + */ + fun create( + playerId: UUID, + playerName: String, + channelId: String, + message: String, + ): ChannelMessageLogEntry = + ChannelMessageLogEntry( + timestamp = Instant.now().toString(), + playerId = playerId.toString(), + playerName = playerName, + channelId = channelId, + message = message, + ) + } +} |
