package jasenmoloy.wirelesscontrol.debug;

import android.content.Context;
import android.support.v7.app.AlertDialog;
import android.util.Log;

/**
 * Created by jasenmoloy on 2/23/16.
 */
public class Debug {

    /**
     * Write debug text out to Logcat.
     */
    public static void LogDebug(String tag, String msg) {
        Log.d(tag, msg);
    }

    /**
     * Write warning text out to Logcat.
     */
    public static void LogWarn(String tag, String msg) {
        Log.w(tag, msg);
    }

    /**
     * Write warning text out to Logcat.
     */
    public static void LogError(String tag, String msg) {
        Log.e(tag, msg);
    }

    /**
     * Write warning text out to Logcat.
     */
    public static void LogVerbose(String tag, String msg) {
        Log.v(tag, msg);
    }

    /**
     * Show a basic debug dialog to provide more info on the built-in debug
     * options.
     */
    public static void ShowDebugOkDialog(Context context, String title, String body) {
        AlertDialog.Builder builder = new AlertDialog.Builder(context)
                .setTitle(title)
                .setMessage(body)
                .setPositiveButton(android.R.string.ok, null);
        builder.create().show();
    }
    public static void ShowDebugOkDialog(Context context, int titleResourceId, String bodyResourceId) {
        AlertDialog.Builder builder = new AlertDialog.Builder(context)
                .setTitle(titleResourceId)
                .setMessage(bodyResourceId)
                .setPositiveButton(android.R.string.ok, null);
        builder.create().show();
    }
}

@@ -329,22 +329,95 @@
     
-Log.d(tag, msg
+if(msg != null)%0A            Log.d(tag, msg);%0A        else%0A            Log.d(tag, %22null%22
 );%0A 
@@ -548,22 +548,95 @@
     
-Log.w(tag, msg
+if(msg != null)%0A            Log.w(tag, msg);%0A        else%0A            Log.w(tag, %22null%22
 );%0A 
@@ -654,39 +654,37 @@
 **%0A     * Write 
-warning
+error
  text out to Log
@@ -766,22 +766,95 @@
     
-Log.e(tag, msg
+if(msg != null)%0A            Log.e(tag, msg);%0A        else%0A            Log.e(tag, %22null%22
 );%0A 
@@ -872,39 +872,39 @@
 **%0A     * Write 
-warning
+verbose
  text out to Log
@@ -988,22 +988,95 @@
     
-Log.v(tag, msg
+if(msg != null)%0A            Log.v(tag, msg);%0A        else%0A            Log.v(tag, %22null%22
 );%0A 

Debug now prints "null" if the string that is passed in is actually rather rather than throwing an exception