AltBeacon / android-beacon-library

Allows Android apps to interact with BLE beacons
Apache License 2.0
2.84k stars 836 forks source link

Add ApiTrackingLogger for troubleshooting complex setups #1078

Closed davidgyoung closed 2 years ago

davidgyoung commented 2 years ago

This adds a ApiTrackingLogger which will keep track of all API calls in an internal array, allowing you to retrieve them at a later time. This is intended to aid in debugging complex library initializations and lifecycle changes by telling you what API calls were made to the library and when.

Example Usage:

LogManager.setLogger(Loggers.apiTrackingLogger())
LogManager.setVerboseLoggingEnabled(true)

...
// Do this later on when you want to see what API calls were logged since library startup:
val apiCalls = Loggers.apiTrackingLogger().getApiCalls()
for (apiCall in apiCalls) {
   Log.d(TAG, apiCall)
}

Sample results from starting the reference app.

2022-03-10 12:50:49.743 API getBeaconParsers, current count 1
2022-03-10 12:50:49.745 API getBeaconParsers, current count 0
2022-03-10 12:50:49.746 API setBeaconLayout m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24
2022-03-10 12:50:49.749 API startMonitoring id1: 2f234454-cf6d-4a0f-adf2-f4911ba9ffa6 id2: null id3: null
2022-03-10 12:50:49.751 API setBackgroundModeIternal true
2022-03-10 12:50:49.752 API updateScanPeriods
2022-03-10 12:50:49.754 API startMonitoringBeaconsInRegion id1: 2f234454-cf6d-4a0f-adf2-f4911ba9ffa6 id2: null id3: null
2022-03-10 12:50:49.788 API getBeaconParsers, current count 1
2022-03-10 12:50:49.802 API startRangingBeacons id1: 2f234454-cf6d-4a0f-adf2-f4911ba9ffa6 id2: null id3: null
2022-03-10 12:50:49.803 API startRangingBeaconsInRegion id1: 2f234454-cf6d-4a0f-adf2-f4911ba9ffa6 id2: null id3: null
2022-03-10 12:50:49.811 API getBeaconParsers, current count 1
2022-03-10 12:50:49.904 API setBackgroundMode false
2022-03-10 12:50:49.905 API setBackgroundModeIternal false
2022-03-10 12:50:49.906 API updateScanPeriods
2022-03-10 12:50:49.915 API getBeaconParsers, current count 1
2022-03-10 12:50:50.047 API setScannerInSameProcess true