Skip to content

Commit 6d28343

Browse files
committed
fix: replace Timber with android.util.Log to fix build error
1 parent 161e230 commit 6d28343

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

app/src/main/java/com/appcontrolx/rollback/RollbackManager.kt

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package com.appcontrolx.rollback
22

33
import android.content.Context
4+
import android.util.Log
45
import com.appcontrolx.executor.CommandExecutor
56
import com.google.gson.Gson
67
import com.google.gson.reflect.TypeToken
7-
import timber.log.Timber
88
import java.io.File
99
import java.util.UUID
1010

@@ -17,8 +17,8 @@ class RollbackManager(
1717
private val snapshotFile = File(snapshotDir, "rollback_snapshot.json")
1818
private val historyFile = File(snapshotDir, "action_history.json")
1919

20-
init {
21-
Timber.d("RollbackManager initialized, historyFile: ${historyFile.absolutePath}")
20+
companion object {
21+
private const val TAG = "RollbackManager"
2222
}
2323

2424
fun saveSnapshot(packages: List<String>): StateSnapshot {
@@ -74,34 +74,27 @@ class RollbackManager(
7474

7575
fun logAction(action: ActionLog) {
7676
try {
77-
Timber.d("Logging action: ${action.action} for ${action.packages.size} packages")
7877
val history = getActionHistory().toMutableList()
7978
history.add(0, action) // Add to beginning
8079

8180
// Keep only last 100 actions
8281
val trimmed = history.take(100)
8382
val json = gson.toJson(trimmed)
8483
historyFile.writeText(json)
85-
Timber.d("Action logged successfully, total logs: ${trimmed.size}")
84+
Log.d(TAG, "Action logged: ${action.action}, total: ${trimmed.size}")
8685
} catch (e: Exception) {
87-
Timber.e(e, "Failed to log action: ${action.action}")
86+
Log.e(TAG, "Failed to log action: ${action.action}", e)
8887
}
8988
}
9089

9190
fun getActionHistory(): List<ActionLog> {
92-
if (!historyFile.exists()) {
93-
Timber.d("History file does not exist")
94-
return emptyList()
95-
}
91+
if (!historyFile.exists()) return emptyList()
9692
return try {
9793
val content = historyFile.readText()
98-
Timber.d("Reading history file, size: ${content.length} bytes")
9994
val type = object : TypeToken<List<ActionLog>>() {}.type
100-
val logs: List<ActionLog>? = gson.fromJson(content, type)
101-
Timber.d("Parsed ${logs?.size ?: 0} logs")
102-
logs ?: emptyList()
95+
gson.fromJson<List<ActionLog>>(content, type) ?: emptyList()
10396
} catch (e: Exception) {
104-
Timber.e(e, "Failed to read action history")
97+
Log.e(TAG, "Failed to read history", e)
10598
emptyList()
10699
}
107100
}

0 commit comments

Comments
 (0)