Skip to content

Commit db31aa8

Browse files
authored
Fixed default LogLevelPresets, app must now include debug info (#33); updated Sentry library
1 parent 66d37f9 commit db31aa8

File tree

6 files changed

+21
-12
lines changed

6 files changed

+21
-12
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file.
44
The format is based on the Steamclock [Release Management Guide](https://github.com/steamclock/labs/wiki/Release-Management-Guide).
55

66
## Unreleased
7+
- Fixed default LogLevelPresets, app must now include debug info (#33)
8+
- Fixed crash on Pixel 4 devices running Android 11 (updated Sentry)
79

810
---
911

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ The `Steamclog.initWith` method can be used to enable external logging; this met
9292

9393
To enable Steamclog to write to the device, you must specify where the files should be stored, this is most easily done by passing along the application's `externalCacheDir` or `cacheDir` references.
9494
```
95-
clog.initWith(fileWritePath = externalCacheDir)
95+
clog.initWith(BuildConfig.DEBUG, fileWritePath = externalCacheDir)
9696
```
9797
* See https://developer.android.com/training/data-storage for details on the pros and cons of each.
9898

@@ -121,12 +121,12 @@ Due to current limitations on how the firebase plugin is applied to projects, yo
121121
The `Steamclog.initWith` method can be used to enable firebase analytics; this method only needs to be called once, and can be done in your Application object's `onCreate` method. If your application has setup Firebase Analytics correctly, the `Firebase.analytics` object should be available to be passed to the initWith method.
122122

123123
```
124-
clog.initWith(firebaseAnalytics = Firebase.analytics)
124+
clog.initWith(BuildConfig.DEBUG, firebaseAnalytics = Firebase.analytics)
125125
```
126126

127127
Both logging and analytics can be initialized at the same time:
128128
```
129-
clog.initWith(fileWritePath = externalCacheDir, firebaseAnalytics = Firebase.analytics)
129+
clog.initWith(BuildConfig.DEBUG, fileWritePath = externalCacheDir, firebaseAnalytics = Firebase.analytics)
130130
```
131131

132132
### Configuration

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,5 @@ dependencies {
9494
implementation 'com.google.firebase:firebase-analytics-ktx:17.4.4'
9595

9696
// https://github.com/getsentry/sentry-android/releases
97-
implementation 'io.sentry:sentry-android:2.3.0'
97+
implementation 'io.sentry:sentry-android:3.1.0'
9898
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.steamclock.steamclogsample
22

33
import android.app.Application
4-
import com.google.firebase.analytics.ktx.analytics
54
import com.google.firebase.ktx.Firebase
5+
import com.google.firebase.analytics.ktx.analytics
66
import com.steamclock.steamclog.clog
77

88
/**
@@ -12,6 +12,6 @@ import com.steamclock.steamclog.clog
1212
class App: Application() {
1313
override fun onCreate() {
1414
super.onCreate()
15-
clog.initWith(fileWritePath = externalCacheDir, firebaseAnalytics = Firebase.analytics)
15+
clog.initWith(BuildConfig.DEBUG, fileWritePath = externalCacheDir, firebaseAnalytics = Firebase.analytics)
1616
}
1717
}

steamclog/src/main/java/com/steamclock/steamclog/Config.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ import java.io.File
99
* Created by shayla on 2020-01-23
1010
*/
1111
data class Config(
12+
/**
13+
* BuildConfig is tied to the module (ie. the Steamclog library module), so we cannot use it to determine
14+
* a default logLevel as this will always be set to false when the library is being imported via JitPack.
15+
* As such this info must be given to us by the application.
16+
*/
17+
val isDebug: Boolean = false,
18+
1219
/**
1320
* Location where the app wishes to store any log files generated (ex. externalCacheDir)
1421
* Required on creation and will not change.
@@ -18,7 +25,7 @@ data class Config(
1825
/**
1926
* Destination logging levels
2027
*/
21-
var logLevel: LogLevelPreset = if (BuildConfig.DEBUG) LogLevelPreset.Firehose else LogLevelPreset.Release,
28+
var logLevel: LogLevelPreset = if (isDebug) LogLevelPreset.Firehose else LogLevelPreset.Release,
2229

2330
/**
2431
* Determines how long generated log files are kept for.
@@ -36,7 +43,7 @@ data class Config(
3643
*/
3744
var firebaseAnalytics: FirebaseAnalytics? = null
3845
) {
39-
constructor(writeFilePath: File) : this(writeFilePath, firebaseAnalytics = null)
46+
constructor(isDebug: Boolean, writeFilePath: File) : this(isDebug, writeFilePath, firebaseAnalytics = null)
4047

4148
override fun toString(): String {
4249
return "Config(" +

steamclog/src/main/java/com/steamclock/steamclog/Steamclog.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ object SteamcLog {
5757
// FirebaseAnalytics instance required before we can start tracking analytics
5858
}
5959

60-
fun initWith(fileWritePath: File? = null, firebaseAnalytics: FirebaseAnalytics? = null) {
60+
fun initWith(isDebug: Boolean, fileWritePath: File? = null, firebaseAnalytics: FirebaseAnalytics? = null) {
6161
fileWritePath?.let {
62-
this.config = Config(fileWritePath)
62+
this.config = Config(isDebug, fileWritePath)
6363
updateTree(externalLogFileTree, true)
6464
}
6565

@@ -74,8 +74,8 @@ object SteamcLog {
7474
* initWith omitting FirebaseAnalytics instance, for applications that
7575
* do not wish to use FirebaseAnalytics.
7676
*/
77-
fun initWith(fileWritePath: File? = null) {
78-
initWith(fileWritePath, null)
77+
fun initWith(isDebug: Boolean, fileWritePath: File? = null) {
78+
initWith(isDebug, fileWritePath, null)
7979
}
8080

8181
//---------------------------------------------

0 commit comments

Comments
 (0)