Java Code Examples for org.altbeacon.beacon.logging.LogManager#setVerboseLoggingEnabled()

The following examples show how to use org.altbeacon.beacon.logging.LogManager#setVerboseLoggingEnabled() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Test
public void testDetectsGattBeacon() {
    org.robolectric.shadows.ShadowLog.stream = System.err;
    LogManager.setLogger(Loggers.verboseLogger());
    LogManager.setVerboseLoggingEnabled(true);
    System.err.println("verbose logging:"+LogManager.isVerboseLoggingEnabled());
    byte[] bytes = hexStringToByteArray("020106030334121516341200e72f234454f4911ba9ffa6000000000001000000000000000000000000000000000000000000000000000000000000000000");
    BeaconParser parser = new BeaconParser().setBeaconLayout("s:0-1=1234,m:2-2=00,p:3-3:-41,i:4-13,i:14-19");
    assertNotNull("Service uuid parsed should not be null", parser.getServiceUuid());
    Beacon gattBeacon = parser.fromScanData(bytes, -55, null, 123456L);
    assertNotNull("GattBeacon should be not null if parsed successfully", gattBeacon);
    assertEquals("id1 should be parsed", "0x2f234454f4911ba9ffa6", gattBeacon.getId1().toString());
    assertEquals("id2 should be parsed", "0x000000000001", gattBeacon.getId2().toString());
    assertEquals("serviceUuid should be parsed", 0x1234, gattBeacon.getServiceUuid());
    assertEquals("txPower should be parsed", -66, gattBeacon.getTxPower());
}
 
Example 2
@Test
public void testDetectsGattBeacon2WithShortIdentifier() {
    org.robolectric.shadows.ShadowLog.stream = System.err;
    LogManager.setLogger(Loggers.verboseLogger());
    LogManager.setVerboseLoggingEnabled(true);
    LogManager.d("GattBeaconTest", "Parsing short packet");
    byte[] bytes = hexStringToByteArray("020106030334121516341210ec007261646975736e6574776f726b7307000000000000000000000000000000000000000000000000000000000000000000");
    BeaconParser parser = new BeaconParser().setBeaconLayout("s:0-1=1234,m:2-2=10,p:3-3:-41,i:4-20v");
    Beacon gattBeacon = parser.fromScanData(bytes, -55, null, 123456L);
    assertNotNull("GattBeacon should be not null if parsed successfully", gattBeacon);
    assertEquals("GattBeacon identifier length should be adjusted smaller if packet is short",
                 16,
                 gattBeacon.getId1().toByteArray().length);
    assertEquals("GattBeacon identifier should have proper first byte",
            (byte)0x00,
            gattBeacon.getId1().toByteArray()[0]);
    assertEquals("GattBeacon identifier should have proper second to last byte",
            (byte) 0x73,
            gattBeacon.getId1().toByteArray()[14]);
    assertEquals("GattBeacon identifier should have proper last byte",
            (byte)0x07,
            gattBeacon.getId1().toByteArray()[15]);

}
 
Example 3
@Test
public void testDetectsUriBeacon() {
    org.robolectric.shadows.ShadowLog.stream = System.err;
    LogManager.setLogger(Loggers.verboseLogger());
    LogManager.setVerboseLoggingEnabled(true);
    //"https://goo.gl/hqBXE1"
    byte[] bytes = {2, 1, 4, 3, 3, (byte) 216, (byte) 254, 19, 22, (byte) 216, (byte) 254, 0, (byte) 242, 3, 103, 111, 111, 46, 103, 108, 47, 104, 113, 66, 88, 69, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    BeaconParser parser = new BeaconParser().setBeaconLayout("s:0-1=fed8,m:2-2=00,p:3-3:-41,i:4-21v");
    LogManager.d("xxx", "------");
    Beacon uriBeacon = parser.fromScanData(bytes, -55, null, 123456L);
    assertNotNull("UriBeacon should be not null if parsed successfully", uriBeacon);
    assertEquals("UriBeacon identifier length should be correct",
            14,
            uriBeacon.getId1().toByteArray().length);
    String urlString = UrlBeaconUrlCompressor.uncompress(uriBeacon.getId1().toByteArray());
    assertEquals("URL should be decompressed successfully", "https://goo.gl/hqBXE1", urlString);
}
 
Example 4
@Before
public void before() {
    org.robolectric.shadows.ShadowLog.stream = System.err;
    LogManager.setLogger(Loggers.verboseLogger());
    LogManager.setVerboseLoggingEnabled(true);
    BeaconManager.setManifestCheckingDisabled(true);
    Context context = RuntimeEnvironment.application;
    new MonitoringStatus(context).clear();
}
 
Example 5
@Before
public void before() {
    org.robolectric.shadows.ShadowLog.stream = System.err;
    LogManager.setLogger(Loggers.verboseLogger());
    LogManager.setVerboseLoggingEnabled(true);
    BeaconManager.setsManifestCheckingDisabled(true);
}
 
Example 6
@Before
public void before() {
    org.robolectric.shadows.ShadowLog.stream = System.err;
    LogManager.setLogger(Loggers.verboseLogger());
    LogManager.setVerboseLoggingEnabled(true);
    BeaconManager.setsManifestCheckingDisabled(true);
}
 
Example 7
@Before
public void before() {
    org.robolectric.shadows.ShadowLog.stream = System.err;
    LogManager.setLogger(Loggers.verboseLogger());
    LogManager.setVerboseLoggingEnabled(true);
    BeaconManager.setsManifestCheckingDisabled(true);
}
 
Example 8
@Test
public void testDetectsGattBeacon2MaxLength() {
    org.robolectric.shadows.ShadowLog.stream = System.err;
    LogManager.setLogger(Loggers.verboseLogger());
    LogManager.setVerboseLoggingEnabled(true);
    byte[] bytes = hexStringToByteArray("020106030334121616341210ec007261646975736e6574776f726b7373070000000000000000000000000000000000000000000000000000000000000000");
    BeaconParser parser = new BeaconParser().setBeaconLayout("s:0-1=1234,m:2-2=10,p:3-3:-41,i:4-20v");
    Beacon gattBeacon = parser.fromScanData(bytes, -55, null, 123456L);
    assertNotNull("GattBeacon should be not null if parsed successfully", gattBeacon);
    assertEquals("GattBeacon identifier length should be proper length",
            17,
            gattBeacon.getId1().toByteArray().length);

}
 
Example 9
@Test
public void testDetectsEddystoneUID() {
    org.robolectric.shadows.ShadowLog.stream = System.err;
    LogManager.setLogger(Loggers.verboseLogger());
    LogManager.setVerboseLoggingEnabled(true);
    byte[] bytes = hexStringToByteArray("0201060303aafe1516aafe00e700010203040506070809010203040506000000000000000000000000000000000000000000000000000000000000000000");
    BeaconParser parser = new BeaconParser().setBeaconLayout(BeaconParser.EDDYSTONE_UID_LAYOUT);
    Beacon eddystoneUidBeacon = parser.fromScanData(bytes, -55, null, 123456L);
    assertNotNull("Eddystone-UID should be not null if parsed successfully", eddystoneUidBeacon);
}
 
Example 10
@Test
public void testDetectsGattBeaconWithCnn() {
    org.robolectric.shadows.ShadowLog.stream = System.err;
    LogManager.setLogger(Loggers.verboseLogger());
    LogManager.setVerboseLoggingEnabled(true);
    LogManager.d("GattBeaconTest", "Parsing short packet");
    byte[] bytes = hexStringToByteArray("020106030334120a16341210ed00636e6e070000000000000000000000000000000000000000000000000000000000000000000000000000000000000000");
    BeaconParser parser = new BeaconParser().setBeaconLayout("s:0-1=1234,m:2-2=10,p:3-3:-41,i:4-20v");
    LogManager.d("xxx", "------");
    Beacon gattBeacon = parser.fromScanData(bytes, -55, null, 123456L);
    assertNotNull("GattBeacon should be not null if parsed successfully", gattBeacon);
    assertEquals("GattBeacon identifier length should be adjusted smaller if packet is short",
            5,
            gattBeacon.getId1().toByteArray().length);
}
 
Example 11
@Test
public void doesNotCrashOnMalformedEddystoneBeacon() {
    org.robolectric.shadows.ShadowLog.stream = System.err;
    LogManager.setLogger(Loggers.verboseLogger());
    LogManager.setVerboseLoggingEnabled(true);
    LogManager.d("GattBeaconTest", "Parsing malformed packet");
    byte[] bytes = hexStringToByteArray("0201060303aafe0416aafe100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000");
    BeaconParser parser = new BeaconParser().setBeaconLayout("s:0-1=feaa,m:2-2=10,p:3-3:-41,i:4-20v");
    LogManager.d("xxx", "------");
    Beacon gattBeacon = parser.fromScanData(bytes, -55, null, 123456L);
    assertNull("GattBeacon should be null when not parsed successfully", gattBeacon);
}
 
Example 12
/**
 * Set to true if you want to show library debugging.
 *
 * @param debug True turn on all logs for this library to be printed out to logcat. False turns
 *              off detailed logging..
 *
 * This is a convenience method that calls setLogger to a verbose logger and enables verbose
 * logging. For more fine grained control, use:
 * {@link org.altbeacon.beacon.logging.LogManager#setLogger(org.altbeacon.beacon.logging.Logger)}
 * instead.
 */
public static void setDebug(boolean debug) {
    if (debug) {
        LogManager.setLogger(Loggers.verboseLogger());
        LogManager.setVerboseLoggingEnabled(true);
    } else {
        LogManager.setLogger(Loggers.empty());
        LogManager.setVerboseLoggingEnabled(false);
    }
}