Android Log log(String msg)

Here you can find the source of log(String msg)

Description

This method allows you to output debug messages only when debugging is on.

Parameter

Parameter Description
TAG Optional parameter to define the tag that the Log will use.
msg The message to output.
type The type of log, 1 for verbose, 2 for error, 3 for debug
exception The exception that was thrown (Needed for errors)

Declaration

public static void log(String msg) 

Method Source Code

//package com.java2s;

public class Main {
    private static boolean debugMode = true;

    /**/*  w  ww .j a va2s.  c  o  m*/
     * This method allows you to output debug messages only when debugging is
     * on. This will allow you to add a debug option to your app, which by
     * default can be left off for performance. However, when you need debugging
     * information, a simple switch can enable it and provide you with detailed
     * logging.
     * <p/>
     * This method handles whether or not to log the information you pass it
     * depending whether or not RootTools.debugMode is on. So you can use this
     * and not have to worry about handling it yourself.
     * 
     * @param TAG
     *            Optional parameter to define the tag that the Log will use.
     * @param msg
     *            The message to output.
     * 
     * @param type
     *            The type of log, 1 for verbose, 2 for error, 3 for debug
     * 
     * @param exception
     *            The exception that was thrown (Needed for errors)
     */
    public static void log(String msg) {
        log(null, msg, 3, null);
    }

    public static void log(String TAG, String msg) {
        log(TAG, msg, 3, null);
    }

    public static void log(String msg, Exception e) {
        log(null, msg, 3, e);
    }

    public static void log(String msg, int type, Exception e) {
        log(null, msg, type, e);
    }

    public static void log(String TAG, String msg, int type, Exception e) {
        if (msg != null && !msg.equals("")) {
            if (debugMode) {
                if (TAG == null) {
                }

                switch (type) {
                case 1:
                    android.util.Log.v(TAG, msg);
                    break;
                case 2:
                    android.util.Log.e(TAG, msg, e);
                    break;
                case 3:
                    android.util.Log.d(TAG, msg);
                    break;
                case 4:
                    android.util.Log.i(TAG, msg);
                    break;
                }
            }
        }
    }
}

Related

  1. debug(String msg)
  2. debug(String tag, String msg)
  3. log(String TAG, String msg)
  4. log(String TAG, String msg, int type, Exception e)
  5. log(String msg, Exception e)
  6. log(String msg, int type, Exception e)
  7. d(String tag, String msg)
  8. d(String tag, String msg, Throwable tr)