Last active
August 29, 2015 14:21
-
-
Save elcioabrahao/72b716564e8d55ced54f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.util.Log; | |
/** | |
* Custom Log - A Facede for Android orignal Log class | |
* Created by elcio on 14/05/15. | |
*/ | |
public class CLog { | |
private static final boolean DEBUG = BuildConfig.BUILD_TYPE.equalsIgnoreCase("debug"); | |
private static String TAG = "YOUR_PROJECT_NAME"; | |
public static void d(Object o) { | |
if(DEBUG) { | |
Log.d(TAG, o.toString()); | |
} | |
} | |
public static void v(Object o) { | |
if(DEBUG) { | |
Log.v(TAG, o.toString()); | |
} | |
} | |
public static void i(Object o) { | |
if(DEBUG) { | |
Log.i(TAG, o.toString()); | |
} | |
} | |
public static void e(Object o) { | |
if(DEBUG) { | |
Log.e(TAG, o.toString()); | |
} | |
} | |
public static void w(Object o) { | |
if(DEBUG) { | |
Log.w(TAG, o.toString()); | |
} | |
} | |
public static void d(Object ot, Object o) { | |
if(DEBUG) { | |
Log.d(ot.toString(), o.toString()); | |
} | |
} | |
public static void v(Object ot, Object o) { | |
if(DEBUG) { | |
Log.v(ot.toString(), o.toString()); | |
} | |
} | |
public static void i(Object ot, Object o) { | |
if(DEBUG) { | |
Log.i(ot.toString(), o.toString()); | |
} | |
} | |
public static void e(Object ot, Object o) { | |
if(DEBUG) { | |
Log.e(ot.toString(), o.toString()); | |
} | |
} | |
public static void w(Object ot, Object o) { | |
if(DEBUG) { | |
Log.w(ot.toString(), o.toString()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Esta classe é um FACADE para a classe Log do Android que permite informar um par de objetos como TAG e MENSAGEM ou somente o objeto da MENSAGEM. Os métodos sobrecarregados chamam o método toString() dos objetos passados como parâmetro. Podem ser passados quaisquer objetos que implementem o método toString(). Os logs somente serão gerados se a build variant for DEBUG. Quando geramos uma variant release nenhum LOG será mostrado.
Para usar faça: CLog.v(Object,Object) para TAG e MENSAGEM ou CLog.v(Object) para MENSAGEM. Todos os modos de debug originais estão disponíveis.