-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
domain/src/main/java/com/lgtm/domain/logging/CommonLoggingScheme.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package com.lgtm.domain.logging | ||
|
||
import com.swm.logging.android.logging_scheme.ClickScheme | ||
import java.lang.reflect.Type | ||
|
||
class CommonLoggingScheme( | ||
eventLogName: String, | ||
screenName: String, | ||
logVersion: String, | ||
logData: Map<String, Any>, | ||
) : ClickScheme() { | ||
|
||
init { | ||
setLoggingScheme( | ||
eventLogName = eventLogName, | ||
screenName = screenName, | ||
logVersion = logVersion, | ||
logData = logData.toMutableMap() | ||
) | ||
} | ||
|
||
class Builder { | ||
private lateinit var eventLogName: String | ||
private lateinit var screenName: String | ||
private var logVersion: String = "1" | ||
private var map = mutableMapOf<String, Any>() | ||
|
||
fun setEventLogName(eventLogName: String): Builder { | ||
this.eventLogName = eventLogName | ||
return this | ||
} | ||
|
||
fun setScreenName(screenName: String): Builder { | ||
this.screenName = screenName | ||
return this | ||
} | ||
|
||
fun setScreenName(type: Type): Builder { | ||
check(type is Class<*>) | ||
this.screenName = type.simpleName | ||
return this | ||
} | ||
|
||
|
||
fun setLogData(map: Map<String, Any>): Builder { | ||
this.map = map.toMutableMap() | ||
return this | ||
} | ||
|
||
fun setLogVersion(logVersion: Int): Builder { | ||
this.logVersion = logVersion.toString() | ||
return this | ||
} | ||
|
||
fun build(): CommonLoggingScheme { | ||
check(::eventLogName.isInitialized) { "eventLogName is not initialized" } | ||
check(::screenName.isInitialized) { "screenName is not initialized" } | ||
|
||
return CommonLoggingScheme( | ||
eventLogName, | ||
screenName, | ||
logVersion, | ||
map | ||
) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters