This repository has been archived by the owner on Jun 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 493
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
File Logger Introduction for Test Builds (EXPOSUREAPP-2640) (#1176)
* Align TestFragment Crash behavior with background transaction crash behavior. * Add logging mechanism to debug hotfix issue. * Lint Resolvement, Nav Graph Issue clean, Enable Log for deviceForTesters, Correct Quota Tests due to now lacking exception Co-authored-by: Matthias Urhahn <[email protected]> Co-authored-by: d067928 <[email protected]>
- Loading branch information
1 parent
e95ff83
commit 90ad5d3
Showing
9 changed files
with
269 additions
and
59 deletions.
There are no files selected for viewing
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
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
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
40 changes: 40 additions & 0 deletions
40
Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/debug/FileLogger.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,40 @@ | ||
package de.rki.coronawarnapp.util.debug | ||
|
||
import android.content.Context | ||
import timber.log.Timber | ||
import java.io.File | ||
|
||
class FileLogger constructor(private val context: Context) { | ||
|
||
val logFile = File(context.cacheDir, "FileLoggerTree.log") | ||
val triggerFile = File(context.filesDir, "FileLoggerTree.trigger") | ||
private var loggerTree: FileLoggerTree? = null | ||
|
||
val isLogging: Boolean | ||
get() = loggerTree != null | ||
|
||
init { | ||
if (triggerFile.exists()) { | ||
start() | ||
} | ||
} | ||
|
||
fun start() { | ||
if (loggerTree != null) return | ||
|
||
loggerTree = FileLoggerTree(logFile).also { | ||
Timber.plant(it) | ||
it.start() | ||
triggerFile.createNewFile() | ||
} | ||
} | ||
|
||
fun stop() { | ||
loggerTree?.let { | ||
it.stop() | ||
logFile.delete() | ||
triggerFile.delete() | ||
loggerTree = null | ||
} | ||
} | ||
} |
Oops, something went wrong.