Skip to content

Colota - Android GPS Location tracker

fix: prefix log tags with Colota, filter native log export, guard pause zone check

Max Dietrichc9c2e24421f8
diff --git a/apps/mobile/android/app/src/main/java/com/colota/bridge/LocationServiceModule.kt b/apps/mobile/android/app/src/main/java/com/colota/bridge/LocationServiceModule.kt
index bbfe3480..464dcfaf 100644
--- a/apps/mobile/android/app/src/main/java/com/colota/bridge/LocationServiceModule.kt
+++ b/apps/mobile/android/app/src/main/java/com/colota/bridge/LocationServiceModule.kt
@@ -57,6 +57,7 @@ class LocationServiceModule(reactContext: ReactApplicationContext) :
companion object {
private const val TAG = "LocationServiceModule"
+
private var reactContextRef: WeakReference<ReactApplicationContext> = WeakReference(null)
@Volatile
@@ -901,7 +902,7 @@ class LocationServiceModule(reactContext: ReactApplicationContext) :
val lines = process.inputStream.bufferedReader().readLines()
process.waitFor()
Arguments.createArray().apply {
- lines.forEach { pushString(it) }
+ lines.filter { "Colota." in it }.forEach { pushString(it) }
}
}
}
diff --git a/apps/mobile/android/app/src/main/java/com/colota/data/DatabaseHelper.kt b/apps/mobile/android/app/src/main/java/com/colota/data/DatabaseHelper.kt
index 628c1d97..e1c393ca 100644
--- a/apps/mobile/android/app/src/main/java/com/colota/data/DatabaseHelper.kt
+++ b/apps/mobile/android/app/src/main/java/com/colota/data/DatabaseHelper.kt
@@ -612,7 +612,7 @@ class DatabaseHelper private constructor(context: Context) :
}
}
} catch (e: Exception) {
- Log.e(TAG, "Error getting days with data", e)
+ AppLogger.e(TAG, "Error getting days with data", e)
}
return days
}
@@ -696,7 +696,7 @@ class DatabaseHelper private constructor(context: Context) :
emitDay()
}
} catch (e: Exception) {
- Log.e(TAG, "Error getting daily stats", e)
+ AppLogger.e(TAG, "Error getting daily stats", e)
}
return stats
}
diff --git a/apps/mobile/android/app/src/main/java/com/colota/util/AppLogger.kt b/apps/mobile/android/app/src/main/java/com/colota/util/AppLogger.kt
index bc10a59b..db621c32 100644
--- a/apps/mobile/android/app/src/main/java/com/colota/util/AppLogger.kt
+++ b/apps/mobile/android/app/src/main/java/com/colota/util/AppLogger.kt
@@ -19,9 +19,13 @@ import com.Colota.BuildConfig
* needing to toggle debug mode, while release users can opt in via the setting.
*
* Errors (Log.e) are always logged regardless of debug mode.
+ *
+ * All tags are prefixed with "Colota." so native log export can filter on that prefix.
*/
object AppLogger {
+ private const val PREFIX = "Colota."
+
@Volatile
var enabled: Boolean = false
@@ -29,18 +33,19 @@ object AppLogger {
get() = enabled || BuildConfig.DEBUG
fun d(tag: String, msg: String) {
- if (active) Log.d(tag, msg)
+ if (active) Log.d(PREFIX + tag, msg)
}
fun i(tag: String, msg: String) {
- if (active) Log.i(tag, msg)
+ if (active) Log.i(PREFIX + tag, msg)
}
fun w(tag: String, msg: String) {
- if (active) Log.w(tag, msg)
+ if (active) Log.w(PREFIX + tag, msg)
}
fun e(tag: String, msg: String, throwable: Throwable? = null) {
- if (throwable != null) Log.e(tag, msg, throwable) else Log.e(tag, msg)
+ val t = PREFIX + tag
+ if (throwable != null) Log.e(t, msg, throwable) else Log.e(t, msg)
}
}
diff --git a/apps/mobile/src/screens/DashboardScreen.tsx b/apps/mobile/src/screens/DashboardScreen.tsx
index ca93f444..cef01144 100644
--- a/apps/mobile/src/screens/DashboardScreen.tsx
+++ b/apps/mobile/src/screens/DashboardScreen.tsx
@@ -110,7 +110,7 @@ export function DashboardScreen({ navigation }: ScreenProps) {
useFocusEffect(
useCallback(() => {
updateStats()
- updatePauseZone()
+ if (tracking) updatePauseZone()
const interval = tracking ? Math.max(settings.interval * 1000, MIN_STATS_INTERVAL_MS) : STATS_REFRESH_IDLE