getLog static method
Returns the contents of the log database as a String
. Provide an optional SQLQuery to contrain results between dates.
Depending on the configured Config.logLevel, the plugin can store an immense amount of helpful logging information for debugging location-tracking problems.
See also:
- Config.logMaxDays (default
3
days) - Config.logLevel (default Config.LOG_LEVEL_OFF)
- emailLog
- uploadLog
Example
// Fetch entire contents of log.
String log = await Logger.getLog();
// Warning: this string could be several megabytes.
print('[log] success: ${log}');
// Or constrain results between optionl start/end dates using a SQLQuery
String log = await Logger.getLog(SQLQuery(
start: DateTime.parse('2019-10-21 13:00'), // <-- optional HH:mm:ss
end: DateTime.parse('2019-10-22')
));
// Or just a start date
String log = await Logger.getLog(SQLQuery(
start: DateTime.parse('2019-10-21 13:00')
));
// Or just an end date
String log = await Logger.getLog(SQLQuery(
end: DateTime.parse('2019-10-21')
));
Example log data:
09-19 11:12:18.716 ╔═════════════════════════════════════════════
09-19 11:12:18.716 ║ BackgroundGeolocation Service started
09-19 11:12:18.716 ╠═════════════════════════════════════════════
09-19 11:12:18.723 [c.t.l.BackgroundGeolocationService d]
09-19 11:12:18.723 ✅ Started in foreground
09-19 11:12:18.737 [c.t.l.ActivityRecognitionService a]
09-19 11:12:18.737 🎾 Start activity updates: 10000
09-19 11:12:18.761 [c.t.l.BackgroundGeolocationService k]
09-19 11:12:18.761 🔴 Stop heartbeat
09-19 11:12:18.768 [c.t.l.BackgroundGeolocationService a]
09-19 11:12:18.768 🎾 Start heartbeat (60)
09-19 11:12:18.778 [c.t.l.BackgroundGeolocationService a]
09-19 11:12:18.778 🔵 setPace: null → false
09-19 11:12:18.781 [c.t.l.adapter.TSConfig c] ℹ️ Persist config
09-19 11:12:18.794 [c.t.locationmanager.util.b a]
09-19 11:12:18.794 ℹ️ LocationAuthorization: Permission granted
09-19 11:12:18.842 [c.t.l.http.HttpService flush]
09-19 11:12:18.842 ╔═════════════════════════════════════════════
09-19 11:12:18.842 ║ HTTP Service
09-19 11:12:18.842 ╠═════════════════════════════════════════════
09-19 11:12:19.000 [c.t.l.BackgroundGeolocationService onActivityRecognitionResult] still (100%)
09-19 11:12:21.314 [c.t.l.l.SingleLocationRequest$2 onLocationResult]
09-19 11:12:21.314 ╔═════════════════════════════════════════════
09-19 11:12:21.314 ║ SingleLocationRequest: 1
09-19 11:12:21.314 ╠═════════════════════════════════════════════
09-19 11:12:21.314 ╟─ 📍 Location[fused 45.519239,-73.617058 hAcc=15]999923706055 vAcc=2 sAcc=??? bAcc=???
09-19 11:12:21.327 [c.t.l.l.TSLocationManager onSingleLocationResult]
09-19 11:12:21.327 🔵 Acquired motionchange position, isMoving: false
09-19 11:12:21.342 [c.t.l.l.TSLocationManager a] 15.243
09-19 11:12:21.405 [c.t.locationmanager.data.a.c persist]
09-19 11:12:21.405 ✅ INSERT: bca5acc8-e358-4d8f-827f-b8c0d556b7bb
09-19 11:12:21.423 [c.t.l.http.HttpService flush]
09-19 11:12:21.423 ╔═════════════════════════════════════════════
09-19 11:12:21.423 ║ HTTP Service
09-19 11:12:21.423 ╠═════════════════════════════════════════════
09-19 11:12:21.446 [c.t.locationmanager.data.a.c first]
09-19 11:12:21.446 ✅ Locked 1 records
09-19 11:12:21.454 [c.t.l.http.HttpService a]
09-19 11:12:21.454 🔵 HTTP POST: bca5acc8-e358-4d8f-827f-b8c0d556b7bb
09-19 11:12:22.083 [c.t.l.http.HttpService$a onResponse]
09-19 11:12:22.083 🔵 Response: 200
09-19 11:12:22.100 [c.t.locationmanager.data.a.c destroy]
09-19 11:12:22.100 ✅ DESTROY: bca5acc8-e358-4d8f-827f-b8c0d556b7bb
09-19 11:12:55.226 [c.t.l.BackgroundGeolocationService onActivityRecognitionResult] still (100%)
Implementation
static Future<String> getLog([SQLQuery? query]) async {
query = (query != null) ? query : new SQLQuery();
return await (_methodChannel.invokeMethod<String>('getLog', query.toMap()))
as FutureOr<String>;
}