Android的日志收集器:Puree
Puree是一個日志收集器,它提供如下一些特性:
- 過濾: 能夠在發送日志前中斷過程。你可以添加一些常用的參數至日志或對日志進行采樣
- 緩存:緩存存儲日志,直到日志被發送
- 批處理:一個請求發送多條日志
- 重試:如果發送日志失敗后,會按設定的時間間隔自動重新發送日志。
幫助你統一你的日志基礎設施。
用法
初始化
Configure Puree on application created.
public class DemoApplication extends Application {
@Override
public void onCreate() {
Puree.initialize(buildConfiguration(this));
}
public static PureeConfiguration buildConfiguration(Context context) {
PureeFilter addEventTimeFilter = new AddEventTimeFilter();
return new PureeConfiguration.Builder(context)
.registerOutput(new OutLogcat())
.registerOutput(new OutBufferedLogcat(), addEventTimeFilter)
.build();
}
} 發送日志
Log class should extend JsonConvertible.
public class ClickLog extends JsonConvertible {
@SerializedName("page")
private String page;
@SerializedName("label")
private String label;
public ClickLog(String page, String label) {
this.page = page;
this.label = label;
}
} Call Puree.send in an arbitary timing.
Puree.send(new ClickLog("MainActivity", "Hello"), OutLogcat.TYPE); 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!
