package com.cangol.mobile.logging;


public class Log {
	// set the LEVEL with VERBOSE value for inner debug version
    //	public static final int LEVEL = android.util.android.util.Log.VERBOSE;

	// set the LEVEL with WARN value to disable debug message for release
	// version
	 public static final int LEVEL = android.util.Log.VERBOSE;

	 public static boolean FORMAT=false;
	// VERBOSE log
    public static void v(String msg) {
			formatLog(android.util.Log.VERBOSE, null, msg, null);
	}
	public static void v(String tag, String msg) {
		formatLog(android.util.Log.VERBOSE, tag, msg, null);
	}

	public static void v(String tag, String msg, Throwable t) {
		formatLog(android.util.Log.VERBOSE, tag, msg, t);
	}

	// INFO log
	public static void i(String msg) {
		formatLog(android.util.Log.INFO, null, msg, null);
	}
	public static void i(String tag, String msg) {
		formatLog(android.util.Log.INFO, tag, msg, null);
	}

	public static void i(String tag, String msg, Throwable t) {
		formatLog(android.util.Log.INFO, tag, msg, t);
	}
	// DEBUG log
	public static void d(String msg) {
		formatLog(android.util.Log.DEBUG, null, msg, null);
	}
	public static void d(String tag, String msg) {
		formatLog(android.util.Log.DEBUG, tag, msg, null);
	}

	public static void d(String tag, String msg, Throwable t) {
		formatLog(android.util.Log.DEBUG, tag, msg, t);
	}
	// WARN log
	public static void w(String msg) {
		formatLog(android.util.Log.WARN, null, msg, null);
	}
	
	public static void w(String tag, String msg) {
		formatLog(android.util.Log.WARN, tag, msg, null);
	}

	public static void w(String tag, String msg, Throwable t) {
		formatLog(android.util.Log.WARN, tag, msg, t);
	}

	// ERROR log
	
	public static void e(String msg) {
		formatLog(android.util.Log.ERROR, null, msg, null);
	}
	
	public static void e(String tag, String msg) {
		formatLog(android.util.Log.ERROR, tag, msg, null);
	}

	public static void e(String tag, String msg, Throwable t) {
		formatLog(android.util.Log.ERROR, tag, msg, t);
	}
	public static void formatLog(int logLevel,String tag,String msg,Throwable error){
		if (LEVEL > logLevel) return;
		StackTraceElement stackTrace = new Throwable().getStackTrace()[2];
		String classname = stackTrace.getClassName();
		String filename = stackTrace.getFileName();
		String methodname = stackTrace.getMethodName();
		int linenumber = stackTrace.getLineNumber();
		String output = null;;
		if(FORMAT){
			output = String.format("%s.%s(%s:%d)-->%s", classname, methodname,filename, linenumber, msg);
		}else{
			output=msg;
		}
		if(null==tag){
			tag= (filename != null && filename.contains(".java"))?filename.replace(".java", ""):"";
		}
		switch (logLevel) {
		case android.util.Log.VERBOSE:
			if (error == null) {
				android.util.Log.v(tag, output);
			} else {
				android.util.Log.v(tag, output, error);
			}
			break;
		case android.util.Log.DEBUG:
			if ( error == null) {
				android.util.Log.d(tag, output);
			} else {
				android.util.Log.d(tag, output,  error);
			}
			break;
		case android.util.Log.INFO:
			if ( error == null) {
				android.util.Log.i(tag, output);
			} else {
				android.util.Log.i(tag, output,  error);
			}
			break;
		case android.util.Log.WARN:
			if ( error == null) {
				android.util.Log.w(tag, output);
			} else {
				android.util.Log.w(tag, output,  error);
			}
			break;
		case android.util.Log.ERROR:
			if ( error == null) {
				android.util.Log.e(tag, output);
			} else {
				android.util.Log.e(tag, output,  error);
			}
			break;
		default:
			break;
		}
	}
}

@@ -58,90 +58,24 @@
 %7B%0D%0A%09
-// set the LEVEL with VERBOSE value for inner debug version%0D%0A    //%09public
+private 
  static 
 fina
@@ -62,38 +62,32 @@
 private  static 
-final 
 int LEVEL = andr
@@ -82,29 +82,16 @@
 LEVEL = 
-android.util.
 android.
@@ -116,94 +116,158 @@
 %0A%0D%0A%09
-// set the LEVEL with WARN value to disable debug message for release%0D%0A%09// version
+private  static boolean FORMAT=false;%0D%0A%09%0D%0A%09public static void setLogLevelFormat(int level,boolean format) %7B%0D%0A%09%09LEVEL = level;%0D%0A%09%09FORMAT=format;%0D%0A%09%7D
 %0D%0A%09
- 
 publ
@@ -280,57 +280,48 @@
 tic 
-final int LEVEL = android.util.Log.VERBOSE
+int getLevel() %7B%0D%0A%09%09return LEVEL
 ;%0D%0A
+%09%7D
 %0D%0A%09
- 
 publ
@@ -338,29 +338,50 @@
 boolean 
-FORMAT=false;
+isFormat() %7B%0D%0A%09%09return FORMAT;%0D%0A%09%7D
 %0D%0A%09// VE
@@ -395,12 +395,11 @@
 og%0D%0A
-    
+%0D%0A%09
 publ
@@ -734,24 +734,27 @@
 / INFO log%0D%0A
+%09%0D%0A
 %09public stat
@@ -1056,24 +1056,27 @@
 g, t);%0D%0A%09%7D%0D%0A
+%09%0D%0A
 %09// DEBUG lo
@@ -1074,24 +1074,27 @@
  DEBUG log%0D%0A
+%09%0D%0A
 %09public stat
@@ -2076,32 +2076,35 @@
 , msg, t);%0D%0A%09%7D%0D%0A
+%09%0D%0A
 %09public static v

add setLogLevelFormat