You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Logs are posted through a `PureeLogger` instance which should be configured with the filters, outputs, store to be used and the log types to be supported, in `Application#onCreate()`.
38
+
39
+
```kotlin
40
+
classMyApplication : Application() {
41
+
lateinitvar logger:PureeLogger
42
+
43
+
overridefunonCreate() {
44
+
logger =PureeLogger.Builder(
45
+
lifecycle =ProcessLifeycleOwner.get().lifecycle,
46
+
logSerializer =MyLogSerializer(),
47
+
logStore =DbPureeLogStore(this, "my_puree.db")
48
+
)
49
+
.filter(
50
+
MyFilter(),
51
+
MyLog::class.java
52
+
)
53
+
.output(
54
+
MyOutput(),
55
+
MyLog::class.java
56
+
)
57
+
.build()
58
+
}
59
+
}
60
+
```
61
+
62
+
## Log objects and serialization
63
+
64
+
Log objects must implement the `PureeLog` interface.
65
+
66
+
```kotlin
67
+
data classMyLog(valeventName:String) : PureeLog
68
+
```
69
+
70
+
Internally, Puree operates on log objects as JSON objects. Puree requires clients to implement a `PureeLogSerializer` that serializes the logs to JSON.
71
+
72
+
Sample serializer using kotlinx.serialization
73
+
74
+
```kotlin
75
+
classMyLogSerializer : PureeLogSerializer {
76
+
overridefunserialize(log:PureeLog): JSONObject {
77
+
val json =Json.encodeToString(log)
78
+
returnJSONObject(json)
79
+
}
80
+
}
81
+
```
82
+
83
+
## Filters
84
+
85
+
`PureeFilter` can be registered to add common fields to specific logs.
0 commit comments