Skip to content

Commit

Permalink
chore: fix tag logging for internal and staging flavors (#2739)
Browse files Browse the repository at this point in the history
  • Loading branch information
saleniuk committed Feb 26, 2024
1 parent 8e38267 commit 295d618
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
16 changes: 9 additions & 7 deletions app/src/internal/kotlin/com/wire/android/util/DataDogLogger.kt
Expand Up @@ -36,13 +36,15 @@ object DataDogLogger : LogWriter() {
.build()

override fun log(severity: Severity, message: String, tag: String, throwable: Throwable?) {
val attributes = KaliumLogger.UserClientData.getFromTag(tag)?.let { userClientData ->
mapOf(
"userId" to userClientData.userId,
"clientId" to userClientData.clientId,
)
} ?: emptyMap<String, Any?>()

val logInfo = KaliumLogger.LogAttributes.getInfoFromTagString(tag)
val userAccountData = mapOf(
"userId" to logInfo.userClientData?.userId,
"clientId" to logInfo.userClientData?.clientId,
)
val attributes = mapOf(
"wireAccount" to userAccountData,
"tag" to logInfo.textTag
)
when (severity) {
Severity.Debug -> logger.d(message, throwable, attributes)
Severity.Info -> logger.i(message, throwable, attributes)
Expand Down
16 changes: 9 additions & 7 deletions app/src/staging/kotlin/com/wire/android/util/DataDogLogger.kt
Expand Up @@ -36,13 +36,15 @@ object DataDogLogger : LogWriter() {
.build()

override fun log(severity: Severity, message: String, tag: String, throwable: Throwable?) {
val attributes = KaliumLogger.UserClientData.getFromTag(tag)?.let { userClientData ->
mapOf(
"userId" to userClientData.userId,
"clientId" to userClientData.clientId,
)
} ?: emptyMap<String, Any?>()

val logInfo = KaliumLogger.LogAttributes.getInfoFromTagString(tag)
val userAccountData = mapOf(
"userId" to logInfo.userClientData?.userId,
"clientId" to logInfo.userClientData?.clientId,
)
val attributes = mapOf(
"wireAccount" to userAccountData,
"tag" to logInfo.textTag
)
when (severity) {
Severity.Debug -> logger.d(message, throwable, attributes)
Severity.Info -> logger.i(message, throwable, attributes)
Expand Down

0 comments on commit 295d618

Please sign in to comment.