Skip to content

Commit

Permalink
Merge pull request #43 from infinum/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
bojankoma authored Jul 21, 2023
2 parents 8654cde + 2becedd commit 91e2e6b
Show file tree
Hide file tree
Showing 31 changed files with 657 additions and 84 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
Change Log
==========

## Version 1.3.0

_2023-07-21_

* Fix log file provider authorities.

## Version 1.2.9

_2023-07-18_

* Update dependencies.
* Persist logs to disk.

## Version 1.2.8

_2023-05-28_
Expand Down
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ Then add the following dependencies in your app `build.gradle` or `build.gradle.
**Groovy**

```groovy
debugImplementation "com.infinum.sentinel:sentinel:1.2.8"
releaseImplementation "com.infinum.sentinel:sentinel-no-op:1.2.8"
debugImplementation "com.infinum.sentinel:sentinel:1.3.0"
releaseImplementation "com.infinum.sentinel:sentinel-no-op:1.3.0"
```

**KotlinDSL**

```kotlin
debugImplementation("com.infinum.sentinel:sentinel:1.2.8")
releaseImplementation("com.infinum.sentinel:sentinel-no-op:1.2.8")
debugImplementation("com.infinum.sentinel:sentinel:1.3.0")
releaseImplementation("com.infinum.sentinel:sentinel-no-op:1.3.0")
```

Basic tools are provided inside the main package but depending on requirements you might want to add
Expand All @@ -74,27 +74,27 @@ specific tools:
**Groovy**

```groovy
debugImplementation "com.infinum.sentinel:tool-chucker:1.2.8"
debugImplementation "com.infinum.sentinel:tool-collar:1.2.8"
debugImplementation "com.infinum.sentinel:tool-dbinspector:1.2.8"
debugImplementation "com.infinum.sentinel:tool-leakcanary:1.2.8"
debugImplementation "com.infinum.sentinel:tool-appgallery:1.2.8"
debugImplementation "com.infinum.sentinel:tool-googleplay:1.2.8"
debugImplementation "com.infinum.sentinel:tool-thimble:1.2.8"
debugImplementation "com.infinum.sentinel:tool-timber:1.2.8"
debugImplementation "com.infinum.sentinel:tool-chucker:1.3.0"
debugImplementation "com.infinum.sentinel:tool-collar:1.3.0"
debugImplementation "com.infinum.sentinel:tool-dbinspector:1.3.0"
debugImplementation "com.infinum.sentinel:tool-leakcanary:1.3.0"
debugImplementation "com.infinum.sentinel:tool-appgallery:1.3.0"
debugImplementation "com.infinum.sentinel:tool-googleplay:1.3.0"
debugImplementation "com.infinum.sentinel:tool-thimble:1.3.0"
debugImplementation "com.infinum.sentinel:tool-timber:1.3.0"
```

**KotlinDSL**

```kotlin
debugImplementation("com.infinum.sentinel:tool-chucker:1.2.8")
debugImplementation("com.infinum.sentinel:tool-collar:1.2.8")
debugImplementation("com.infinum.sentinel:tool-dbinspector:1.2.8")
debugImplementation("com.infinum.sentinel:tool-leakcanary:1.2.8")
debugImplementation("com.infinum.sentinel:tool-appgallery:1.2.8")
debugImplementation("com.infinum.sentinel:tool-googleplay:1.2.8")
debugImplementation("com.infinum.sentinel:tool-thimble:1.2.8")
debugImplementation("com.infinum.sentinel:tool-timber:1.2.8")
debugImplementation("com.infinum.sentinel:tool-chucker:1.3.0")
debugImplementation("com.infinum.sentinel:tool-collar:1.3.0")
debugImplementation("com.infinum.sentinel:tool-dbinspector:1.3.0")
debugImplementation("com.infinum.sentinel:tool-leakcanary:1.3.0")
debugImplementation("com.infinum.sentinel:tool-appgallery:1.3.0")
debugImplementation("com.infinum.sentinel:tool-googleplay:1.3.0")
debugImplementation("com.infinum.sentinel:tool-thimble:1.3.0")
debugImplementation("com.infinum.sentinel:tool-timber:1.3.0")
```

Now you can sync your project.
Expand Down
4 changes: 2 additions & 2 deletions config.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ext {
def major = 1
def minor = 2
def patch = 8
def minor = 3
def patch = 0

buildConfig = [
"minSdk" : 21,
Expand Down
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[versions]
sentinel = "1.2.8"
gradle = "8.0.1"
sentinel = "1.3.0"
gradle = "8.0.2"
desugar = "2.0.3"
kotlin = "1.8.21"
coroutines = "1.7.1"
Expand All @@ -25,7 +25,7 @@ ktlintplugin = "11.3.1"
ktlint = "0.45.2"
cpd = "3.3"
dokka = "1.8.10"
chucker = "3.5.2"
chucker = "4.0.0"
collar = "1.4.0"
dbinspector = "5.4.9"
leakcanary = "2.11"
Expand Down
14 changes: 11 additions & 3 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,17 @@ dependencies {
implementation libs.material
implementation libs.timber

debugImplementation libs.library
// debugImplementation project(":sentinel")
// debugImplementation libs.library
debugImplementation project(":sentinel")
releaseImplementation libs.librarynoop

debugImplementation libs.bundles.tools
// debugImplementation libs.bundles.tools
debugImplementation project(":tool-appgallery")
debugImplementation project(":tool-chucker")
debugImplementation project(":tool-collar")
debugImplementation project(":tool-dbinspector")
debugImplementation project(":tool-googleplay")
debugImplementation project(":tool-leakcanary")
debugImplementation project(":tool-thimble")
debugImplementation project(":tool-timber")
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import com.infinum.sentinel.ui.shared.edgetreatment.ScissorsEdgeTreatment

@Suppress("TooManyFunctions")
@RestrictTo(RestrictTo.Scope.LIBRARY)
internal class SentinelFragment : BaseFragment<SentinelState, SentinelEvent>(R.layout.sentinel_fragment) {
internal class SentinelFragment :
BaseFragment<SentinelState, SentinelEvent>(R.layout.sentinel_fragment) {

companion object {
const val TAG: String = "SentinelFragment"
Expand Down Expand Up @@ -59,8 +60,8 @@ internal class SentinelFragment : BaseFragment<SentinelState, SentinelEvent>(R.l

override fun onEvent(event: SentinelEvent) =
when (event) {
is SentinelEvent.Formatted -> ShareCompat.IntentBuilder(requireActivity())
.shareText(event.value)
is SentinelEvent.Formatted ->
ShareCompat.IntentBuilder(requireActivity()).shareText(event.value)
}

private fun setupToolbar() {
Expand Down
2 changes: 1 addition & 1 deletion sentinel/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
<string name="sentinel_priority">Priority</string>
<string name="sentinel_message">Message</string>

<string name="sentinel_logger_empty">No logs collected.</string>
<string name="sentinel_logger_empty">No new logs collected.</string>

<string name="sentinel_certificate">Certificate</string>
<string name="sentinel_certificates_empty">No certificates collected.</string>
Expand Down
1 change: 1 addition & 0 deletions tool-timber/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ dokkaJavadoc {
}

dependencies {
coreLibraryDesugaring libs.desugar
implementation libs.kotlin.core
implementation libs.coroutines
api libs.library
Expand Down
21 changes: 21 additions & 0 deletions tool-timber/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@
android:value="false" />
</activity>

<activity
android:name=".ui.logs.LogsActivity"
android:exported="false"
android:label="@string/sentinel_logs"
android:taskAffinity="com.infinum.sentinel.logger"
android:theme="@style/Sentinel.Theme.Leaf">
<meta-data
android:name="@string/sentinel_infinum_monitored"
android:value="false" />
</activity>

<provider
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
Expand All @@ -24,6 +35,16 @@
android:value="androidx.startup" />
</provider>

<provider
android:name=".SentinelLogsProvider"
android:authorities="${applicationId}.sentinel.logprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/sentinel_file_paths"/>
</provider>

</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -1,30 +1,42 @@
package com.infinum.sentinel

import android.content.Context
import com.infinum.sentinel.ui.logger.models.BaseEntry
import com.infinum.sentinel.ui.logger.models.FlowBuffer
import com.infinum.sentinel.ui.logger.models.Level
import com.infinum.sentinel.ui.shared.LogFileResolver
import java.io.File
import java.util.Calendar
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import timber.log.Timber

internal class SentinelTree(
internal class SentinelFileTree(
context: Context,
val buffer: FlowBuffer<Entry>
) : Timber.DebugTree() {

private val logFileResolver = LogFileResolver(context)

override fun log(priority: Int, tag: String?, message: String, t: Throwable?) {
MainScope().launch {
withContext(Dispatchers.IO) {
buffer.enqueue(
Entry(
Level.forLogLevel(priority),
System.currentTimeMillis(),
tag,
message,
t?.stackTraceToString()
)
val entry = Entry(
Level.forLogLevel(priority),
System.currentTimeMillis(),
tag,
message,
t?.stackTraceToString()
)

buffer.enqueue(entry)

val file: File = logFileResolver.createOrOpenFile()
val line = entry.asLineString()

file.appendText(line)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.infinum.sentinel

import androidx.core.content.FileProvider

internal class SentinelLogsProvider : FileProvider(R.xml.sentinel_file_paths)
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ public class TimberInitializer : Initializer<Class<TimberInitializer>> {
override fun create(context: Context): Class<TimberInitializer> {

Timber.plant(
SentinelTree(
SentinelFileTree(
context,
FlowBuffer()
)
)
Expand Down
Loading

0 comments on commit 91e2e6b

Please sign in to comment.