Skip to content

Commit

Permalink
loco-core 1.1.0 🎉
Browse files Browse the repository at this point in the history
  • Loading branch information
sys1yagi committed May 20, 2019
1 parent 383285b commit 5e26266
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 82 deletions.
127 changes: 55 additions & 72 deletions README.md
Expand Up @@ -14,7 +14,7 @@ Add your necessary module.
```groovy
dependencies {
// core
implementation 'com.sys1yagi.loco:loco-core:1.0.1'
implementation 'com.sys1yagi.loco:loco-core:1.1.0'
// optional, use Gson to serialize the log, and you can use filters to process the logs.
implementation 'com.sys1yagi.loco:loco-smasher-filterable-gson:1.0.0'
Expand All @@ -37,17 +37,14 @@ fun startLoco() {
LocoConfig(
store = InMemoryStore(), // persistent layer for buffering logs.
smasher = GsonSmasher(Gson()), // serializer for logs.
senders = listOf(
StdOutSender() // log senders
senders = mapOf(
// log senders and mapping
StdOutSender() to listOf(
ClickLog::class
)
),
scheduler = IntervalSendingScheduler(5000L), // sending interval scheduler
sendingBulkSize = 20
) {
// mapping logs to sender
logToSender[StdOutSender::class] = listOf(
ClickLog::class
)
}
scheduler = IntervalSendingScheduler(5000L) // sending interval scheduler
)
)

// send logs anytime, anywhere
Expand Down Expand Up @@ -131,38 +128,15 @@ class SampleApplication : Application() {
smasher = FilterableGsonSmasher(Gson()), // loco-smasher-filterable-gson
senders = // ...
scheduler = // ...
) {
// ...
}
)
)
}
}
```

See more [sample](https://github.com/sys1yagi/loco/tree/master/sample)

## Sender Mapping

You should mapping for logs and sender.


```kotlin
Loco.start(
LocoConfig(
store = // ...,
smasher = // ...,
senders = listOf(
NetworkSender()
),
scheduler = // ...,
) {
logToSender[NetworkSender::class] = listOf(
ClickLog::class,
ScreenLog::class
)
}
)
```
## Multi Sender

You can configure multiple Senders.

Expand All @@ -171,20 +145,17 @@ Loco.start(
LocoConfig(
store = // ...,
smasher = // ...,
senders = listOf(
NetworkSender(),
LogcatSender()
senders = mapOf(
NetworkSender() to listOf(
ClickLog::class,
ScreenLog::class
),
LogcatSender() to listOf(
ScreenLog::class
)
),
scheduler = // ...,
) {
logToSender[NetworkSender::class] = listOf(
ClickLog::class,
ScreenLog::class
)
logToSender[LogcatSender::class] = listOf(
ScreenLog::class
)
}
)
)
```

Expand Down Expand Up @@ -303,7 +274,19 @@ class IntervalSendingScheduler(val interval: Long) : SendingScheduler {
}
```

## Internist
## LocoConfig.Extra

TODO

## defaultSender

TODO

## sendingBulkSize

TODO

### Internist

What's happening in Loco?
You can make an internist intrude.
Expand All @@ -316,30 +299,30 @@ Loco.start(
smasher = //... ,
senders = //... ,
scheduler = //... ,
internist = object : Internist {
override fun onSend(locoLog: LocoLog, config: LocoConfig) {
println("onSend")
}

override fun onStore(log: SmashedLog, config: LocoConfig) {
println("onStore")
LocoConfig.Extra(
internist = object : Internist {
override fun onSend(locoLog: LocoLog, config: LocoConfig) {
println("onSend")
}

override fun onStore(log: SmashedLog, config: LocoConfig) {
println("onStore")
}

override fun onStartSending() {
println("onStartSending")
}

override fun onSending(sender: Sender, logs: List<SmashedLog>, config: LocoConfig) {
println("onSending: $sender, ${logs.size}")
}

override fun onEndSending(sendingResults: List<Pair<Sender, SendingResult>>, config: LocoConfig) {
println("onStartSending")
}
}

override fun onStartSending() {
println("onStartSending")
}

override fun onSending(sender: Sender, logs: List<SmashedLog>, config: LocoConfig) {
println("onSending: $sender, ${logs.size}")
}

override fun onEndSending(sendingResults: List<Pair<Sender, SendingResult>>, config: LocoConfig) {
println("onStartSending")
}
}
) {
//...
}
)
)
)
```

Expand Down
2 changes: 1 addition & 1 deletion loco-core/build.gradle
@@ -1,7 +1,7 @@
apply plugin: 'java-library'
apply plugin: 'kotlin'

ext.versionName = '1.0.1'
ext.versionName = '1.1.0'
ext.moduleName = "Log core module"

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
Expand Down
2 changes: 1 addition & 1 deletion sample/build.gradle
Expand Up @@ -24,7 +24,7 @@ android {
}

dependencies {
implementation 'com.sys1yagi.loco:loco-core:1.0.1'
implementation 'com.sys1yagi.loco:loco-core:1.1.0'
implementation 'com.sys1yagi.loco:loco-smasher-filterable-gson:1.0.0'
implementation 'com.sys1yagi.loco:loco-store-android-sqlite:1.0.0'

Expand Down
Expand Up @@ -22,16 +22,14 @@ class SampleApplication : Application() {
LocoConfig(
store = LocoAndroidSqliteStore(this),
smasher = FilterableGsonSmasher(Gson()),
senders = listOf(
LogcatSender()
senders = mapOf(
LogcatSender() to listOf(
ClickLog::class,
ScreenLog::class
)
),
scheduler = IntervalSendingScheduler(5000)
) {
logToSender[LogcatSender::class] = listOf(
ClickLog::class,
ScreenLog::class
)
}
)
)
}

Expand Down

0 comments on commit 5e26266

Please sign in to comment.