Skip to content

Commit 71b850f

Browse files
committed
update readme
1 parent e18e986 commit 71b850f

File tree

2 files changed

+88
-6
lines changed

2 files changed

+88
-6
lines changed

README.md

Lines changed: 86 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
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
36114
Please 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

sample/ios-app/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ PODS:
7171
- PromisesObjC (1.2.10)
7272

7373
DEPENDENCIES:
74-
- Firebase
74+
- Firebase (= 6.33.0)
7575
- FirebaseCrashlytics
7676
- MultiPlatformLibrary (from `../mpp-library`)
7777

@@ -107,6 +107,6 @@ SPEC CHECKSUMS:
107107
nanopb: 59317e09cf1f1a0af72f12af412d54edf52603fc
108108
PromisesObjC: b14b1c6b68e306650688599de8a45e49fae81151
109109

110-
PODFILE CHECKSUM: e2c288540b0b80c13ea5efa9eef52317283eeedc
110+
PODFILE CHECKSUM: cda8a19268eedbd8de1aa68cc1eba57c7ea56ffb
111111

112112
COCOAPODS: 1.9.3

0 commit comments

Comments
 (0)