-
Notifications
You must be signed in to change notification settings - Fork 378
feat(logger): [SDK-4939] wire Android FileLogStore for shared KMP legacy purge #2691
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
aa6d9e9
feat(logger): [SDK-4939] wire Android FileLogStore for shared legacy …
c1066c9
fix(logger): [SDK-4939] clarify suspend purge ordering and cover cras…
fadi-george 23fa36e
test: [SDK-4939] raise callback timeout on immediate-drop notificatio…
fadi-george 8034317
fix(ci): [SDK-4939] evaluate skip-coverage label outside shell quoting
fadi-george File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
67 changes: 67 additions & 0 deletions
67
...core/src/main/java/com/onesignal/debug/internal/logging/logger/android/CrashDirCleanup.kt
This file contains hidden or 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,67 @@ | ||
| package com.onesignal.debug.internal.logging.logger.android | ||
|
|
||
| /** | ||
| * Pure, Android-free helpers for the shared logger/otel crash directory. | ||
| * | ||
| * Ownership is suffix-based: logger-owned records end in [CRASH_OWNED_SUFFIX]; everything else | ||
| * (legacy otel bare-millis names, stray `.tmp`s) is foreign. Keeping this logic free of | ||
| * `File` / `Logging` / Robolectric means it is counted by Jacoco on the plain JVM. | ||
| */ | ||
| internal const val CRASH_OWNED_SUFFIX = ".otlp" | ||
|
|
||
| internal data class CrashDirEntry( | ||
| val name: String, | ||
| val lastModifiedMs: Long, | ||
| val lengthBytes: Long = 0L, | ||
| ) | ||
|
|
||
| /** True when [name] is a logger-owned crash record. */ | ||
| internal fun isOwnedCrashFile(name: String, ownedSuffix: String = CRASH_OWNED_SUFFIX): Boolean = | ||
| name.endsWith(ownedSuffix) | ||
|
|
||
| /** | ||
| * Returns foreign/legacy entries old enough to reclaim. Owned `*.otlp` names are never selected, | ||
| * regardless of age. | ||
| */ | ||
| internal fun selectUnrecognizedEntries( | ||
| entries: List<CrashDirEntry>, | ||
| nowMs: Long, | ||
| minAgeMillis: Long, | ||
| ownedSuffix: String = CRASH_OWNED_SUFFIX, | ||
| ): List<CrashDirEntry> = | ||
| entries.filter { entry -> | ||
| !isOwnedCrashFile(entry.name, ownedSuffix) && | ||
| nowMs - entry.lastModifiedMs >= minAgeMillis | ||
| } | ||
|
|
||
| /** | ||
| * Builds the human-readable crash-dir inventory line used for rollout verification. | ||
| * Per-file detail is capped at [maxSample] so Logcat is not flooded. | ||
| */ | ||
| internal fun formatCrashDirInventory( | ||
| label: String, | ||
| path: String, | ||
| entries: List<CrashDirEntry>, | ||
| nowMs: Long, | ||
| maxSample: Int, | ||
| ownedSuffix: String = CRASH_OWNED_SUFFIX, | ||
| ): String { | ||
| if (entries.isEmpty()) { | ||
| return "OneSignal: Crash storage inventory [$label] ($path): empty" | ||
| } | ||
| val otlp = entries.count { isOwnedCrashFile(it.name, ownedSuffix) } | ||
| val legacy = entries.size - otlp | ||
| val sample = entries.take(maxSample) | ||
| val summary = | ||
| sample.joinToString(separator = "; ") { entry -> | ||
| "name=${entry.name} bytes=${entry.lengthBytes} ageMs=${nowMs - entry.lastModifiedMs}" | ||
| } | ||
| val truncated = | ||
| if (entries.size > maxSample) { | ||
| " …(+${entries.size - maxSample} more)" | ||
| } else { | ||
| "" | ||
| } | ||
| return "OneSignal: Crash storage inventory [$label] ($path): " + | ||
| "total=${entries.size} otlp=$otlp legacy=$legacy [$summary]$truncated" | ||
| } |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.