-
Notifications
You must be signed in to change notification settings - Fork 275
Debugging
The BackgroundGeolocation SDK includes a verbose and configurable Logger API.
<+37.33517518,-122.03255055> +/- 5.00m (speed 2.41 mps / course 184.57) @ 11/14/16, 9:04:59 AM GMT-05:00
╔═══════════════════════════════════════════════════════════
║ -[TSLocationManager locationManager:didUpdateLocations:] Enabled: 1 | isMoving: 1 | distanceFilter: 10.0
╚═══════════════════════════════════════════════════════════
- Median location accuracy: 5.0
🔵-[Settings incrementOdometer:] 358.3
✅ [BackgroundTaskManager createBackgroundTask]: 11
✅ INSERT: ACF76983-145B-40CA-9555-3667AAEBFDB5
╔═══════════════════════════════════════════════════════════
║ -[TSHttpService flush]
╚═══════════════════════════════════════════════════════════
✅ LOCKED: ACF76983-145B-40CA-9555-3667AAEBFDB5
🔵-[TSHttpService doPost:] HTTP Response: 201
2016-11-14 09:04:59.498 BG Geo[23652:5892283] [js] location: [object Object]
✅ [BackgroundTaskManager stopBackgroundTask] 11 OF (
)
✅ DESTROY: ACF76983-145B-40CA-9555-3667AAEBFDB5
╔═══════════════════════════════════════════════════════════
║ -[TSHttpService finish:] Success: 1
╚═══════════════════════════════════════════════════════════
Use the config Config.logLevel
to adjust the verbosity of the logging, from 0: NONE
to 5: VERBOSE
. The default is LOG_LEVEL_VERBOSE
. WARNING: Do not publish an app with LOG_LEVEL_VERBOSE
.
logLevel | Label |
---|---|
0 |
LOG_LEVEL_OFF |
1 |
LOG_LEVEL_ERROR |
2 |
LOG_LEVEL_WARNING |
3 |
LOG_LEVEL_INFO |
4 |
LOG_LEVEL_DEBUG |
5 |
LOG_LEVEL_VERBOSE |
BackgroundGeolocation.ready({
logLevel: bgGeo.LOG_LEVEL_VERBOSE,
debug: true // <-- enable debug sounds/notifications
});
By default, the plugin stores three days worth of logs to its database. You may configure logMaxDays
) to store any number of days you wish.
Use the method Logger.getLog
to retrieve the current contents of the log from the database as a single String
. Warning: The log can be very large, several megabytes.
BackgroundGeolocation.logger.getLog(function(log) {
console.log(log);
});
You may also use the method Logger.emailLog
. This will fetch the current log and send it using the device's default mail client, appending the log as an email-attachment.
BackgroundGeolocation.logger.emailLog('[email protected]').then((success) => {
console.log('[emailLog] SUCCESS');
}).catch((error) => {
console.log('[emailLog] ERROR: ', error);
});
When testing at your work-station, you can observe the plugin logs in XCode:
When testing the plugin at your work-station, you should always observe the Android logs via adb logcat
. You can filter the log to receive only messages from the plugin by using the TAG TSLocationManager:V
(V
for verbose). It's also helpful to use chromium:V
so you can see console.log
message from your Cordova App.
$ adb logcat *:S TSLocationManager:V chromium:V
08:52:06.678 TSLocationManager: ╔═════════════════════════════════════════════
08:52:06.678 TSLocationManager: ║ BackgroundGeolocation Service started
08:52:06.678 TSLocationManager: ╠═════════════════════════════════════════════
08:52:06.686 TSLocationManager: [c.t.l.BackgroundGeolocationService c]
08:52:06.686 TSLocationManager: ✅ Started in foreground
08:52:06.730 TSLocationManager: [c.t.l.a.BackgroundGeolocation requestActivityUpdates]
08:52:06.730 TSLocationManager: 🎾 Start activity updates: 10000
08:52:06.743 TSLocationManager: [c.t.l.BackgroundGeolocationService a]
08:52:06.743 TSLocationManager: 🔵 setPace: null → true
08:52:06.752 TSLocationManager: [c.t.l.BackgroundGeolocationService i]
08:52:06.752 TSLocationManager: 🔴 Stop heartbeat
08:52:09.227 TSLocationManager: [c.t.l.LocationService onLocation]
08:52:09.227 TSLocationManager: ╔═════════════════════════════════════════════
08:52:09.227 TSLocationManager: ║ LocationService: location:1008
08:52:09.227 TSLocationManager: ╠═════════════════════════════════════════════
08:52:09.227 TSLocationManager: ╟─ 📍 Location[fused 45.519350,-73.616967 acc=19 et=+20h20m16s147ms]
08:52:09.254 TSLocationManager: [c.t.l.l.TSLocationManager onSingleLocationResult]
08:52:09.254 TSLocationManager: 🔵 Acquired motionchange position
08:52:09.263 TSLocationManager: [c.t.l.l.TSLocationManager calculateMedianAccuracy] 19.4925
08:52:09.272 TSLocationManager: [c.t.l.l.TSLocationManager incrementOdometer] 0.0
08:52:09.285 TSLocationManager: [c.t.locationmanager.geofence.b a]
08:52:09.285 TSLocationManager: ╔═════════════════════════════════════════════
08:52:09.285 TSLocationManager: ║ TSGeofenceManager found 0/1 within 1000.0 meters
08:52:09.285 TSLocationManager: ╚═════════════════════════════════════════════
08:52:09.302 TSLocationManager: [c.t.l.l.TSLocationManager requestLocationUpdates]
08:52:09.302 TSLocationManager: 🎾 Location-services: ON
08:52:09.318 TSLocationManager: $ finish()
08:52:09.326 TSLocationManager: $ finish()
08:52:09.346 TSLocationManager: [c.t.l.d.s.SQLiteLocationDAO persist]
08:52:09.346 TSLocationManager: ✅ INSERT: 24833494-b2ca-4f4b-baae-ba846655384d
08:52:09.375 TSLocationManager: [c.t.l.LocationService onLocation]
08:52:09.375 TSLocationManager: ╔═════════════════════════════════════════════
08:52:09.375 TSLocationManager: ║ LocationService: location
08:52:09.375 TSLocationManager: ╠═════════════════════════════════════════════
08:52:09.375 TSLocationManager: ╟─ 📍 Location[fused 45.519350,-73.616967 acc=19 et=+20h20m16s371ms]
08:52:09.383 TSLocationManager: [c.t.l.http.HttpService flush]
08:52:09.383 TSLocationManager: ╔═════════════════════════════════════════════
08:52:09.383 TSLocationManager: ║ HTTP Service
08:52:09.383 TSLocationManager: ╠═════════════════════════════════════════════
08:52:09.390 TSLocationManager: [c.t.l.l.TSLocationManager onLocationResult]
08:52:09.390 TSLocationManager: ╔═════════════════════════════════════════════
08:52:09.390 TSLocationManager: ║ Process LocationResult
08:52:09.390 TSLocationManager: ╠═════════════════════════════════════════════
08:52:09.412 TSLocationManager: [c.t.l.l.TSLocationManager onLocationResult]
08:52:09.412 TSLocationManager: [c.t.l.d.s.SQLiteLocationDAO first]
08:52:09.412 TSLocationManager: ✅ Locked 1 records
08:52:09.419 TSLocationManager: [c.t.l.http.HttpService createRequest]
08:52:09.419 TSLocationManager: 🔵 POST: 24833494-b2ca-4f4b-baae-ba846655384d
08:52:09.453 TSLocationManager: [c.t.l.http.HttpRequest parseNetworkResponse]
08:52:09.453 TSLocationManager: 🔵 Response: 201
08:52:09.468 TSLocationManager: [c.t.l.d.s.SQLiteLocationDAO destroy]
08:52:09.468 TSLocationManager: ✅ DESTROY: 24833494-b2ca-4f4b-baae-ba846655384d
iOS location can be simulated in the iOS Simulator. In the Simulator->Debug menu:
If you wish to do geofence testing in the iOS Simulator, The SampleApp contains a handy JSON file of the the City Drive route which you can use to populate the plugin with geofences. The SampleApp has a debug screen which uses this JSON data to Clear & Load these geofences:
When deploying to the device, you can simulate location by installing the app Lockito from Google Play Store. You must enable Lockito in Settings:
Settings->Developer Options->Select Mock Location App
.
NOTE: Once you configure a route in Lockito, you'll have to manually engage tracking in the plugin to trigger a state-change from Stationary -> Moving either by SHAKING the device to simulate motion or manually by executing the bgGeo.changePace(true)
.
Unfortunately, Lockito has a bug which makes it fail to respond to geofences (it used to work in previous versions), probably related to this
The Activity Recognition System will sample the device's current activity as configured with #activityRecognitionInterval (ms)
(e.g.: 10000 means the system will sample the current activity every 10 seconds).
- Activity received: still, confidence: 100
-
When the plugin receives on of the "moving" activities (e.g.:
"on_foot", "in_vehicle"
) location-updates will be initiated. -
You can easily simulate the
on_foot
state by shaking the device vigorously until the next#activityRecognitionInterval
ticks over). You'll hear the sound "doodly-doo" when location-updates are initiated.