mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
36 lines
929 B
Kotlin
36 lines
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) {
|
||
|
|
|
||
|
|
}
|