Android Open Source - BluetoothHidEmu Do Log






From Project

Back to project page BluetoothHidEmu.

License

The source code is released under:

Apache License

If you think the Android project BluetoothHidEmu listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package andraus.bluetoothhidemu.util;
//w ww  .j  a va  2s .  co  m
import java.util.HashMap;
import java.util.Map;

import android.util.Log;

/**
 * Wrapper for android.util.Log. This class will check for the proper log level before writing messages to the log
 * This class uses a cache in order to reduce overhead for Log.isLoggable() calls. The cache may be disabled by 
 * setting USE_CACHE to false.
 * 
 * Note: to enable the logs for your tag, use:
 * 
 * - adb shell setprop log.tag.<TAG> <LEVEL>
 * 
 * e.g.
 * 
 * - adb shell setprop log.tag.BluetoothKeyb DEBUG
 * 
 * 
 * @author andraus
 *
 */
public class DoLog {
    
    private static boolean USE_CACHE = true;
    private static Map<String, Boolean> cacheMap = new HashMap<String, Boolean>();

    private static boolean isLoggable(String tag, int level) {
        
        if (!USE_CACHE) {
            return Log.isLoggable(tag, level);
        } else {
        
            String key = tag + "-" + level;
            
            Boolean isLoggable = cacheMap.get(key);
            
            if (isLoggable == null) {
                isLoggable = Boolean.valueOf(Log.isLoggable(tag, level));
                cacheMap.put(key, isLoggable);
            }       
            
            return isLoggable.booleanValue();
        }
        
    }
    
    public static void v(String tag, String msg) {
        if (isLoggable(tag, Log.VERBOSE)) {
            Log.v(tag, msg);
        }
    }
    public static void v(String tag, String msg, Exception e) {
        if (isLoggable(tag, Log.VERBOSE)) {
            Log.v(tag, msg, e);
        }
    }
    
    public static void d(String tag, String msg) {
        if (isLoggable(tag, Log.DEBUG)) {
            Log.d(tag, msg);
        }
    }
    public static void d(String tag, String msg, Exception e) {
        if (isLoggable(tag, Log.DEBUG)) {
            Log.d(tag, msg, e);
        }
    }
    
    public static void i(String tag, String msg) {
        if (isLoggable(tag, Log.INFO)) {
            Log.i(tag, msg);
        }
    }
    public static void i(String tag, String msg, Exception e) {
        if (isLoggable(tag, Log.INFO)) {
            Log.i(tag, msg, e);
        }
    }
    
    public static void w(String tag, String msg) {
        if (isLoggable(tag, Log.WARN)) {
            Log.w(tag, msg);
        }
    }
    public static void w(String tag, String msg, Exception e) {
        if (isLoggable(tag, Log.WARN)) {
            Log.w(tag, msg, e);
        }
    }
    
    public static void e(String tag, String msg) {
        if (isLoggable(tag, Log.ERROR)) {
            Log.e(tag, msg);
        }
    }
    public static void e(String tag, String msg, Exception e) {
        if (isLoggable(tag, Log.ERROR)) {
            Log.e(tag, msg, e);
        }
    }

}




Java Source Code List

andraus.bluetoothhidemu.BluetoothHidEmuActivity.java
andraus.bluetoothhidemu.ButtonClickListener.java
andraus.bluetoothhidemu.Constants.java
andraus.bluetoothhidemu.KeyboardKeyListener.java
andraus.bluetoothhidemu.KeyboardTextWatcher.java
andraus.bluetoothhidemu.SpecialKeyListener.java
andraus.bluetoothhidemu.TouchpadListener.java
andraus.bluetoothhidemu.settings.BluetoothAdapterStateReceiver.java
andraus.bluetoothhidemu.settings.BluetoothDeviceStateReceiver.java
andraus.bluetoothhidemu.settings.Settings.java
andraus.bluetoothhidemu.sock.BluetoothSocketThread.java
andraus.bluetoothhidemu.sock.SocketManager.java
andraus.bluetoothhidemu.sock.payload.HidConsumerPayload.java
andraus.bluetoothhidemu.sock.payload.HidKeyPair.java
andraus.bluetoothhidemu.sock.payload.HidKeyboardPayload.java
andraus.bluetoothhidemu.sock.payload.HidPayload.java
andraus.bluetoothhidemu.sock.payload.HidPointerPayload.java
andraus.bluetoothhidemu.sock.payload.HidSixaxisPayload.java
andraus.bluetoothhidemu.spoof.BluetoothAdapterSpooferFactory.java
andraus.bluetoothhidemu.spoof.BluetoothAdapterSpooferGeneric.java
andraus.bluetoothhidemu.spoof.BluetoothAdapterSpooferMotoReflect.java
andraus.bluetoothhidemu.spoof.BluetoothAdapterSpooferMoto.java
andraus.bluetoothhidemu.spoof.BluetoothAdapterSpoofer.java
andraus.bluetoothhidemu.spoof.CleanupExceptionHandler.java
andraus.bluetoothhidemu.spoof.Spoof.java
andraus.bluetoothhidemu.spoof.jni.BluetoothSocketJni.java
andraus.bluetoothhidemu.ui.GenericUiControls.java
andraus.bluetoothhidemu.ui.Ps3KeypadUiControls.java
andraus.bluetoothhidemu.ui.UiControls.java
andraus.bluetoothhidemu.util.DoLog.java
andraus.bluetoothhidemu.view.ArrowButton.java
andraus.bluetoothhidemu.view.BluetoothDeviceArrayAdapter.java
andraus.bluetoothhidemu.view.BluetoothDeviceView.java
andraus.bluetoothhidemu.view.EchoEditText.java
andraus.bluetoothhidemu.view.ViewUtils.java