-
Notifications
You must be signed in to change notification settings - Fork 3
CHANGE logging from Napier to Kermit #200
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
6 commits
Select commit
Hold shift + click to select a range
4a66e02
ADD kermit dependency
ninovanhooff 897924f
ADD initial usage of Kermit
ninovanhooff 83063e0
REMOVE remaining Napier occurrences
ninovanhooff 2bdb809
REMOVE Napier dependency
ninovanhooff c42bfe7
CHANGE release logging level from Warn to Info
ninovanhooff 47c96d5
Merge branch 'develop' into feature/template-199-kermit-logger
ninovanhooff 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,9 +27,3 @@ | |
| } | ||
|
|
||
| ## END enums | ||
|
|
||
| ## START napier | ||
| -keep class io.github.aakira.napier.** { | ||
| *; | ||
| } | ||
| ## END napier | ||
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
44 changes: 44 additions & 0 deletions
44
app/src/main/kotlin/nl/q42/template/logging/CrashlyticsLogWriter.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,44 @@ | ||
| package nl.q42.template.logging | ||
|
|
||
| import co.touchlab.kermit.LogWriter | ||
| import co.touchlab.kermit.Severity | ||
| import com.google.firebase.Firebase | ||
| import com.google.firebase.crashlytics.crashlytics | ||
|
|
||
| /** A value suitable for Crashlytics | ||
| * This value is used to truncate the user-defined message and the exception message | ||
| * In theory, the message sent to Crashlytics could therefore be 2x this value | ||
| */ | ||
| private const val MAX_CHARS_IN_LOG = 1200 | ||
|
|
||
| /** | ||
| * A Crashlytics logger. Logs Severity.Error as Non-Fatal and less severe messages will be added | ||
| * to the next crashlytics event (crash, non-fatal or ANR) as breadcrumbs | ||
| */ | ||
| class CrashlyticsLogWriter : LogWriter() { | ||
| override fun log( | ||
| severity: Severity, | ||
| message: String, | ||
| tag: String, | ||
| throwable: Throwable? | ||
| ) { | ||
|
|
||
| val limitedMessage = | ||
| message.take(MAX_CHARS_IN_LOG) // to avoid OutOfMemoryError's | ||
|
|
||
| if (severity < Severity.Error) { | ||
| val errorMessage = throwable?.let { | ||
| " with error: ${throwable}: ${throwable.message}".take(MAX_CHARS_IN_LOG) | ||
| } ?: "" | ||
| Firebase.crashlytics.log(limitedMessage + errorMessage) | ||
| } else { | ||
| Firebase.crashlytics.log("recordException with message: $limitedMessage") | ||
| Firebase.crashlytics.recordException( | ||
| throwable ?: Exception( | ||
| limitedMessage, | ||
| ) | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| } |
104 changes: 0 additions & 104 deletions
104
app/src/main/kotlin/nl/q42/template/logging/CrashlyticsLogger.kt
This file was deleted.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,5 +13,5 @@ android { | |
| } | ||
|
|
||
| dependencies { | ||
| implementation(libs.napier) | ||
| } | ||
| implementation(libs.kermit) | ||
| } | ||
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
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 |
|---|---|---|
|
|
@@ -67,4 +67,4 @@ private fun ColumnScreenContentPreview() { | |
| } | ||
| }, | ||
| ) | ||
| } | ||
| } | ||
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
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
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.