Change logging for nRF Toolbox

This commit is contained in:
Sylwester Zieliński
2022-04-04 13:16:26 +02:00
parent b5d542f967
commit 6ffbd9b07b
10 changed files with 11 additions and 10 deletions

View File

@@ -11,6 +11,7 @@ internal const val LOG_TAG = "nRF Toolbox"
class ToolboxLogger( class ToolboxLogger(
private val context: Context, private val context: Context,
private val profile: String,
private val key: String, private val key: String,
) { ) {
@@ -25,7 +26,7 @@ class ToolboxLogger(
} }
private fun getLogger(): LogSession? { private fun getLogger(): LogSession? {
logSession = logSession ?: Logger.newSession(context, key, LOG_TAG) logSession = logSession ?: Logger.newSession(context, profile, key, LOG_TAG)
return logSession return logSession
} }
} }

View File

@@ -23,7 +23,7 @@ internal class BPSRepository @Inject constructor(
fun downloadData(device: BluetoothDevice): Flow<BleManagerResult<BPSData>> = callbackFlow { fun downloadData(device: BluetoothDevice): Flow<BleManagerResult<BPSData>> = callbackFlow {
val scope = this val scope = this
val manager = BPSManager(context, scope, ToolboxLogger(context, "BPS")) val manager = BPSManager(context, scope, ToolboxLogger(context, "BPS", device.address))
manager.dataHolder.status.onEach { manager.dataHolder.status.onEach {
trySend(it) trySend(it)

View File

@@ -35,7 +35,7 @@ class CGMRepository @Inject constructor(
} }
fun start(device: BluetoothDevice, scope: CoroutineScope) { fun start(device: BluetoothDevice, scope: CoroutineScope) {
val manager = CGMManager(context, scope, ToolboxLogger(context, "CGMS")) val manager = CGMManager(context, scope, ToolboxLogger(context, "CGMS", device.address))
this.manager = manager this.manager = manager
manager.dataHolder.status.onEach { manager.dataHolder.status.onEach {

View File

@@ -36,7 +36,7 @@ class CSCRepository @Inject constructor(
} }
fun start(device: BluetoothDevice, scope: CoroutineScope) { fun start(device: BluetoothDevice, scope: CoroutineScope) {
val manager = CSCManager(context, scope, ToolboxLogger(context, "CSC")) val manager = CSCManager(context, scope, ToolboxLogger(context, "CSC", device.address))
this.manager = manager this.manager = manager
manager.dataHolder.status.onEach { manager.dataHolder.status.onEach {

View File

@@ -29,7 +29,7 @@ internal class GLSRepository @Inject constructor(
fun downloadData(device: BluetoothDevice): Flow<BleManagerResult<GLSData>> = callbackFlow { fun downloadData(device: BluetoothDevice): Flow<BleManagerResult<GLSData>> = callbackFlow {
val scope = this val scope = this
val managerInstance = manager ?: GLSManager(context, scope, ToolboxLogger(context, "GLS")).apply { val managerInstance = manager ?: GLSManager(context, scope, ToolboxLogger(context, "GLS", device.address)).apply {
try { try {
connect(device) connect(device)
.useAutoConnect(false) .useAutoConnect(false)

View File

@@ -35,7 +35,7 @@ class HRSRepository @Inject constructor(
} }
fun start(device: BluetoothDevice, scope: CoroutineScope) { fun start(device: BluetoothDevice, scope: CoroutineScope) {
val manager = HRSManager(context, scope, ToolboxLogger(context, "HRS")) val manager = HRSManager(context, scope, ToolboxLogger(context, "HRS", device.address))
this.manager = manager this.manager = manager
manager.dataHolder.status.onEach { manager.dataHolder.status.onEach {

View File

@@ -35,7 +35,7 @@ class HTSRepository @Inject constructor(
} }
fun start(device: BluetoothDevice, scope: CoroutineScope) { fun start(device: BluetoothDevice, scope: CoroutineScope) {
val manager = HTSManager(context, scope, ToolboxLogger(context, "HTS")) val manager = HTSManager(context, scope, ToolboxLogger(context, "HTS", device.address))
this.manager = manager this.manager = manager
manager.dataHolder.status.onEach { manager.dataHolder.status.onEach {

View File

@@ -37,7 +37,7 @@ class PRXRepository @Inject internal constructor(
} }
fun start(device: BluetoothDevice, scope: CoroutineScope) { fun start(device: BluetoothDevice, scope: CoroutineScope) {
val manager = PRXManager(context, scope, ToolboxLogger(context, "PRX")) val manager = PRXManager(context, scope, ToolboxLogger(context, "PRX", device.address))
this.manager = manager this.manager = manager
manager.useServer(proximityServerManager) manager.useServer(proximityServerManager)

View File

@@ -35,7 +35,7 @@ class RSCSRepository @Inject constructor(
} }
fun start(device: BluetoothDevice, scope: CoroutineScope) { fun start(device: BluetoothDevice, scope: CoroutineScope) {
val manager = RSCSManager(context, scope, ToolboxLogger(context, "RSCS")) val manager = RSCSManager(context, scope, ToolboxLogger(context, "RSCS", device.address))
this.manager = manager this.manager = manager
manager.dataHolder.status.onEach { manager.dataHolder.status.onEach {

View File

@@ -37,7 +37,7 @@ class UARTRepository @Inject internal constructor(
} }
fun start(device: BluetoothDevice, scope: CoroutineScope) { fun start(device: BluetoothDevice, scope: CoroutineScope) {
val manager = UARTManager(context, scope, ToolboxLogger(context, "UART")) val manager = UARTManager(context, scope, ToolboxLogger(context, "UART", device.address))
this.manager = manager this.manager = manager
manager.dataHolder.status.onEach { manager.dataHolder.status.onEach {