1-
1+ [ ![ GitHub license ] ( https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat )] ( http://www.apache.org/licenses/LICENSE-2.0 ) [ ![ Download ]
22![ kotlin-version] ( https://img.shields.io/badge/kotlin-1.4.10-orange )
33
44# Mobile Kotlin crash report
55
6- coming soon.. .
6+ This is a Kotlin MultiPlatform library that provides reporting fatal and non-fatal exceptions from common code .
77
88## Table of Contents
99- [ Features] ( #features )
@@ -17,7 +17,8 @@ coming soon...
1717- [ License] ( #license )
1818
1919## Features
20-
20+ - ** CrashlyticsLogger** implementation of ** ExceptionLogger** , for logging messages and non-fatals to FirebaseCrashlytics.
21+ - ** CrashReportingAntilog** can be used for ** Napier** logger to log messages and errors by ** ExceptionLogger**
2122
2223## Requirements
2324- Gradle version 6.0+
@@ -29,13 +30,94 @@ coming soon...
2930 - 0.1.0
3031
3132## Installation
32-
33+ root build.gradle
34+ ``` groovy
35+ allprojects {
36+ repositories {
37+ maven { url = "https://dl.bintray.com/icerockdev/moko" }
38+ maven { url = uri("https://dl.bintray.com/aakira/maven") } // for CrashReportingAntilog
39+ }
40+ }
41+ ```
42+ project build.gradle
43+ ``` groovy
44+ dependencies {
45+ commonMainApi("dev.icerock.moko:crash-reporting-core:0.1.0")
46+ commonMainApi("dev.icerock.moko:crash-reporting-crashlytics:0.1.0") // for CrashlyticsLogger
47+ commonMainApi("dev.icerock.moko:crash-reporting-napier:0.1.0") // for CrashReportingAntilog
48+ commonMainImplementation("com.github.aakira:napier:1.4.1") // for CrashReportingAntilog
49+ }
50+ ```
51+ For CrashlyticsLogger need to add FirebaseCrashlytics cocoapod
52+ With [ mobile-multiplatform-gradle-plugin] ( https://github.com/icerockdev/mobile-multiplatform-gradle-plugin ) cocoapods configuration simplest:
53+ ` build.gradle.kts ` :
54+ ``` kotlin
55+ cocoaPods {
56+ podsProject = file(" ios-app/Pods/Pods.xcodeproj" )
57+
58+ pod(" GoogleUtilities" , onlyLink = false )
59+ pod(" FirebaseCrashlytics" , onlyLink = true )
60+ }
61+ ```
62+ project Podfile
63+ ``` ruby
64+ pod ' Firebase' , ' 6.33.0'
65+ pod ' FirebaseCrashlytics' , ' 4.6.1'
66+ ```
3367## Usage
3468
69+ ### CrashlyticsLogger
70+ If you haven't already, add Firebase to your project, you can see how to do it [ here] ( https://firebase.google.com/docs/crashlytics/get-started )
71+
72+ ``` kotlin
73+ val logger = CrashlyticsLogger ()
74+
75+ // setting user id in crashlytics
76+ logger.setUserId(" User_1" )
77+
78+ // setting custom key-value in crashlytics
79+ logger.setCustomValue(" customValue" , " customKey" )
80+
81+ // log message in crashlytics
82+ logger.log(" Hello World" )
83+
84+ // send non-fatal exception to crashlytics
85+ try {
86+ " test" .toInt()
87+ } catch (e: NumberFormatException ) {
88+ logger.recordException(e)
89+ }
90+ ```
91+
92+ ### CrashReportingAntilog
93+ ``` kotlin
94+ val logger = CrashlyticsLogger () // CrashlyticsLogger for example, you can use any ExceptionLogger implementation
95+
96+ // initialize napier
97+ Napier .base(antilog = CrashReportingAntilog (exceptionLogger = logger))
98+
99+ // All messages will be logged by exceptionLogger
100+ Napier .d(message = " Hello World" )
101+ Napier .i(message = " This is random message" , tag = " FYI" )
102+ Napier .w(message = " Something goes wrong" , tag = " Alarm" )
103+ Napier .v(message = " just verbose" , tag = " VERBOSE" )
104+
105+ // throwable will be recorded by exceptionLogger
106+ try {
107+ " test" .toInt()
108+ } catch (e: NumberFormatException ) {
109+ Napier .e(message = " test is not a number" , tag = " Non fatal" , throwable = e)
110+ }
111+ ```
112+
35113## Samples
36114Please see more examples in the [ sample directory] ( sample ) .
37115
38116## Set Up Locally
117+ - The [ crash-reporting-core] ( crash-reporting-core ) contains basic classes and interfaces needed for crash reporting;
118+ - The [ crash-reporting-crashlytics] ( crash-reporting-crashlytics ) contains integraion with firebase crashlytics;
119+ - The [ crash-reporting-napier] ( crash-reporting-napier ) contains integration with [ napier] ( https://github.com/AAkira/Napier ) logger;
120+ - The [ sample directory] ( sample ) contains sample apps for Android and iOS; plus the mpp-library connected to the apps.
39121
40122
41123## Contributing
0 commit comments