Custom Logger for Own Application

by Sunday, September 01, 2013 0 comments
Use this custom logger for your own application, from these you can disable particular log type without deleting from activity

 import android.util.Log;  


 public class AppLog { 

      // Log levels (low to high) 

      // VERBOSE - 1,DEBUG - 2, INFO - 3, WARN - 4, ERROR -5 

      // Log.v(TAG, "verbose is active: " + Log.isLoggable(TAG, Log.VERBOSE)); 

      // Log.e(TAG, "debug is active: " + Log.isLoggable(TAG, Log.DEBUG)); 

      // Log.i(TAG, "info is active: " + Log.isLoggable(TAG, Log.INFO)); 

      // Log.w(TAG, "warn is active: " + Log.isLoggable(TAG, Log.WARN)); 

      // Log.e(TAG, "error is active: " + Log.isLoggable(TAG, Log.ERROR)); 

      public static boolean LOG_LEVEL_VERBOSE = true; 

      public static boolean LOG_LEVEL_DEBUG = true; 

      public static boolean LOG_LEVEL_INFO = true; 

      public static boolean LOG_LEVEL_WARN = true; 

      public static boolean LOG_LEVEL_ERROR = true; 

      public static void v(String TAG, String msg) { 

           if (Log.isLoggable(TAG, Log.VERBOSE) && LOG_LEVEL_VERBOSE) { 

                Log.v(TAG, msg); 

           } 

      } 

      public static void d(String TAG, String msg) { 

           if (Log.isLoggable(TAG, Log.DEBUG) && LOG_LEVEL_DEBUG) { 

                Log.e(TAG, msg); 

           } 

      } 

      public static void i(String TAG, String msg) { 

           if (Log.isLoggable(TAG, Log.INFO) && LOG_LEVEL_INFO) { 

                Log.i(TAG, msg); 

           } 

      } 

      public static void w(String TAG, String msg) { 

           if (Log.isLoggable(TAG, Log.WARN) && LOG_LEVEL_WARN) { 

                Log.w(TAG, msg); 

           } 

      } 

      public static void e(String TAG, String msg) { 

           if (Log.isLoggable(TAG, Log.ERROR) && LOG_LEVEL_ERROR) { 

                Log.e(TAG, msg); 

           } 

      } 

 } 

Unknown

Androider

Welcome to Android-Action Blog. I’m a normal guy, who is passionate about Mobile Coding. Here I am writing about Android. Happy learning

0 comments:

Post a Comment