Skip to content

Commit

Permalink
Added roomLogger to DefaultRoom, initialized features accordingly
Browse files Browse the repository at this point in the history
  • Loading branch information
sacOO7 committed Nov 25, 2024
1 parent 5cd21cf commit 8a49288
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions chat-android/src/main/java/com/ably/chat/Room.kt
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,9 @@ internal class DefaultRoom(
private val realtimeClient: RealtimeClient,
chatApi: ChatApi,
clientId: String,
private val logger: Logger,
logger: Logger,
) : Room {
private val roomLogger = logger.withContext("Room", mapOf("roomId" to roomId))

/**
* RoomScope is a crucial part of the Room lifecycle. It manages sequential and atomic operations.
Expand All @@ -128,7 +129,7 @@ internal class DefaultRoom(
roomId = roomId,
realtimeChannels = realtimeClient.channels,
chatApi = chatApi,
logger = logger.withContext(tag = "Messages"),
logger = roomLogger.withContext(tag = "Messages"),
)

private var _presence: Presence? = null
Expand Down Expand Up @@ -167,7 +168,7 @@ internal class DefaultRoom(
return _occupancy as Occupancy
}

private val statusLifecycle = DefaultRoomLifecycle(logger)
private val statusLifecycle = DefaultRoomLifecycle(roomLogger)

override val status: RoomStatus
get() = statusLifecycle.status
Expand All @@ -187,7 +188,7 @@ internal class DefaultRoom(
clientId = clientId,
channel = messages.channel,
presence = messages.channel.presence,
logger = logger.withContext(tag = "Presence"),
logger = roomLogger.withContext(tag = "Presence"),
)
roomFeatures.add(presenceContributor)
_presence = presenceContributor
Expand All @@ -199,7 +200,7 @@ internal class DefaultRoom(
realtimeClient = realtimeClient,
clientId = clientId,
options = options.typing,
logger = logger.withContext(tag = "Typing"),
logger = roomLogger.withContext(tag = "Typing"),
)
roomFeatures.add(typingContributor)
_typing = typingContributor
Expand All @@ -210,7 +211,7 @@ internal class DefaultRoom(
roomId = roomId,
clientId = clientId,
realtimeChannels = realtimeClient.channels,
logger = logger.withContext(tag = "Reactions"),
logger = roomLogger.withContext(tag = "Reactions"),
)
roomFeatures.add(reactionsContributor)
_reactions = reactionsContributor
Expand All @@ -221,13 +222,13 @@ internal class DefaultRoom(
roomId = roomId,
realtimeChannels = realtimeClient.channels,
chatApi = chatApi,
logger = logger.withContext(tag = "Occupancy"),
logger = roomLogger.withContext(tag = "Occupancy"),
)
roomFeatures.add(occupancyContributor)
_occupancy = occupancyContributor
}

lifecycleManager = RoomLifecycleManager(roomScope, statusLifecycle, roomFeatures, logger)
lifecycleManager = RoomLifecycleManager(roomScope, statusLifecycle, roomFeatures, roomLogger)
}

override fun onStatusChange(listener: RoomLifecycle.Listener): Subscription =
Expand Down

0 comments on commit 8a49288

Please sign in to comment.