Skip to content

Commit

Permalink
Added condition if we have logs file in the previous version for addi…
Browse files Browse the repository at this point in the history
…ng the rest of the date
  • Loading branch information
Aitorbp committed Feb 7, 2024
1 parent 033f539 commit c12ed38
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,16 @@ class OCFileLoggingTree(
it.list()?.let { logFiles ->
if (logFiles.isNotEmpty()) {

val lastDateLogFileString = if (context != null) {
var lastDateLogFileString = if (context != null) {
logFiles.last().substringAfterLast("${context.packageName}.").substringBeforeLast(".log")
} else {
logFiles.last().substringAfterLast("$filename.").substringBeforeLast(".log")
}

val dateFormat = SimpleDateFormat(LOG_FILE_TIME_FORMAT)
if (lastDateLogFileString.matches("^\\d{4}-\\d{2}-\\d{2}$".toRegex())) {
lastDateLogFileString = "${lastDateLogFileString}_00.00.00"
}
val lastDayLogFileDate = dateFormat.parse(lastDateLogFileString)
val newDayLogFileDate = dateFormat.parse(fileNameTimestamp)

Expand Down

0 comments on commit c12ed38

Please sign in to comment.