Skip to content

Commit

Permalink
Fix oppia#5232: ConsoleLogger overwrites local log file for each line…
Browse files Browse the repository at this point in the history
… write
  • Loading branch information
kmanikanta335 committed Dec 19, 2023
1 parent 49a481d commit 3ffe3cb
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ class ConsoleLogger @Inject constructor(
private val machineLocale: OppiaLocale.MachineLocale
) {
private val logDirectory = File(context.filesDir, "oppia_app.log")
private val logStream = PrintWriter(OutputStreamWriter(FileOutputStream(logDirectory, true), Charsets.UTF_8))
private val logStream = PrintWriter(
OutputStreamWriter(FileOutputStream(logDirectory, true), Charsets.UTF_8)
)

/** Logs a verbose message with the specified tag. */
fun v(tag: String, msg: String) {
Expand Down Expand Up @@ -92,7 +94,9 @@ class ConsoleLogger @Inject constructor(
Log.println(logLevel.logLevel, tag, fullLog)
}
if (enableFileLog) {
logStream.println("${machineLocale.computeCurrentTimeString()}\t${logLevel.name}/$tag: $fullLog")
logStream.println(
"${machineLocale.computeCurrentTimeString()}\t${logLevel.name}/$tag: $fullLog"
)
logStream.flush()
}
}
Expand Down

0 comments on commit 3ffe3cb

Please sign in to comment.