Skip to content

Commit

Permalink
Updated Logging interface and interaction.
Browse files Browse the repository at this point in the history
- Pulled into sperate package
- Added var args to wait out rendering of strings until needed.
  • Loading branch information
AndrewReitz committed Feb 1, 2015
1 parent 849de88 commit 94520a8
Show file tree
Hide file tree
Showing 27 changed files with 372 additions and 500 deletions.
7 changes: 4 additions & 3 deletions src/main/java/org/altbeacon/beacon/Beacon.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.altbeacon.beacon.client.BeaconDataFactory;
import org.altbeacon.beacon.client.NullBeaconDataFactory;
import org.altbeacon.beacon.distance.DistanceCalculator;
import org.altbeacon.beacon.logging.LogManager;

import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -295,7 +296,7 @@ public double getDistance() {
bestRssiAvailable = mRunningAverageRssi;
}
else {
BeaconManager.d(TAG, "Not using running average RSSI because it is null");
LogManager.d(TAG, "Not using running average RSSI because it is null");
}
mDistance = calculateDistance(mTxPower, bestRssiAvailable);
}
Expand Down Expand Up @@ -421,7 +422,7 @@ public int describeContents() {
*/
public void writeToParcel(Parcel out, int flags) {
out.writeInt(mIdentifiers.size());
BeaconManager.d(TAG, "serializing identifiers of size "+mIdentifiers.size());
LogManager.d(TAG, "serializing identifiers of size %s", mIdentifiers.size());
for (Identifier identifier: mIdentifiers) {
out.writeString(identifier == null ? null : identifier.toString());
}
Expand Down Expand Up @@ -453,7 +454,7 @@ protected static Double calculateDistance(int txPower, double bestRssiAvailable)
return Beacon.getDistanceCalculator().calculateDistance(txPower, bestRssiAvailable);
}
else {
BeaconManager.e(TAG, "Distance calculator not set. Distance will bet set to -1");
LogManager.e(TAG, "Distance calculator not set. Distance will bet set to -1");
return -1.0;
}
}
Expand Down
15 changes: 7 additions & 8 deletions src/main/java/org/altbeacon/beacon/BeaconIntentProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,28 @@
*/
package org.altbeacon.beacon;

import org.altbeacon.beacon.logging.LogManager;
import org.altbeacon.beacon.service.MonitoringData;
import org.altbeacon.beacon.service.RangingData;

import android.annotation.TargetApi;
import android.app.IntentService;
import android.content.Intent;
import android.util.Log;

/**
* Converts internal intents to notifier callbacks
*/
@TargetApi(3)
public class BeaconIntentProcessor extends IntentService {
private static final String TAG = "BeaconIntentProcessor";
private boolean initialized = false;

public BeaconIntentProcessor() {
super("BeaconIntentProcessor");
}

@Override
protected void onHandleIntent(Intent intent) {
BeaconManager.d(TAG, "got an intent to process");
LogManager.d(TAG, "got an intent to process");

MonitoringData monitoringData = null;
RangingData rangingData = null;
Expand All @@ -56,17 +55,17 @@ protected void onHandleIntent(Intent intent) {
}

if (rangingData != null) {
BeaconManager.d(TAG, "got ranging data");
LogManager.d(TAG, "got ranging data");
if (rangingData.getBeacons() == null) {
BeaconManager.w(TAG, "Ranging data has a null beacons collection");
LogManager.w(TAG, "Ranging data has a null beacons collection");
}
RangeNotifier notifier = BeaconManager.getInstanceForApplication(this).getRangingNotifier();
java.util.Collection<Beacon> beacons = rangingData.getBeacons();
if (notifier != null) {
notifier.didRangeBeaconsInRegion(beacons, rangingData.getRegion());
}
else {
BeaconManager.d(TAG, "but ranging notifier is null, so we're dropping it.");
LogManager.d(TAG, "but ranging notifier is null, so we're dropping it.");
}
RangeNotifier dataNotifier = BeaconManager.getInstanceForApplication(this).getDataRequestNotifier();
if (dataNotifier != null) {
Expand All @@ -75,10 +74,10 @@ protected void onHandleIntent(Intent intent) {

}
if (monitoringData != null) {
BeaconManager.d(TAG, "got monitoring data");
LogManager.d(TAG, "got monitoring data");
MonitorNotifier notifier = BeaconManager.getInstanceForApplication(this).getMonitoringNotifier();
if (notifier != null) {
BeaconManager.d(TAG, "Calling monitoring notifier:"+notifier);
LogManager.d(TAG, "Calling monitoring notifier: %s", notifier);
notifier.didDetermineStateForRegion(monitoringData.isInside() ? MonitorNotifier.INSIDE : MonitorNotifier.OUTSIDE, monitoringData.getRegion());
if (monitoringData.isInside()) {
notifier.didEnterRegion(monitoringData.getRegion());
Expand Down
Loading

0 comments on commit 94520a8

Please sign in to comment.