Meshtastic-Android/app/src/main/java/com/geeksville/mesh/android/DebugLogFile.kt
2022-09-04 22:52:40 -03:00

36 lines
No EOL
929 B
Kotlin

package com.geeksville.mesh.android
import android.content.Context
import java.io.File
import java.io.FileOutputStream
import java.io.PrintWriter
/**
* Create a debug log on the SD card (if needed and allowed and app is configured for debugging (FIXME)
*
* write strings to that file
*/
class DebugLogFile(context: Context, name: String) {
val stream = FileOutputStream(File(context.getExternalFilesDir(null), name), true)
val file = PrintWriter(stream)
fun close() {
file.close()
}
fun log(s: String) {
file.println(s) // FIXME, optionally include timestamps
file.flush() // for debugging
}
}
/**
* Create a debug log on the SD card (if needed and allowed and app is configured for debugging (FIXME)
*
* write strings to that file
*/
class BinaryLogFile(context: Context, name: String) :
FileOutputStream(File(context.getExternalFilesDir(null), name), true) {
}