我的Android進階之旅------>Android關於Log的一個簡單封裝

來源:互聯網
上載者:User

標籤:ora   bottom   http   一個   nal   hit   csdn   java   .net   

android.util.Log類,能夠方便地用於在編碼調試過程中列印日誌。

可是在公布後的產品中,假設有太多的日誌列印。則會嚴重地影響效能。

對android.util.Log類做一個簡單的封裝。當產品要公布的話,將Debug設為false。

代碼例如以下。

public class LogUtil {/**正式上線時候設為false*/private final static boolean debug = true;private final static String TAG = "oyp";public static void v(String tag, String msg) {if (debug) {Log.v(tag, msg);}}public static void v(String msg) {if (debug) {Log.v(TAG, msg);}}public static void d(String tag, String msg) {if (debug) {Log.d(tag, msg);}}public static void d(String msg) {if (debug) {Log.d(TAG, msg);}}public static void i(String tag, String msg) {if (debug) {Log.i(tag, msg);}}public static void i(String msg) {if (debug) {Log.i(TAG, msg);}}public static void w(String tag, String msg) {if (debug) {Log.w(tag, msg);}}public static void w(String msg) {if (debug) {Log.w(TAG, msg);}}public static void e(String tag, String msg) {if (debug) {Log.e(tag, msg);}}public static void e(String msg) {if (debug) {Log.e(TAG, msg);}}}


 



                            ====================================================================================

  歐陽鵬  歡迎轉載,與人分享是進步的源泉!

  轉載請保留原文地址:http://blog.csdn.net/ouyang_peng

====================================================================================

 


我的Android進階之旅------>Android關於Log的一個簡單封裝

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.