My Android advanced tour ------ & gt; Android's simple Log encapsulation, android advanced

Source: Internet
Author: User

My Android advanced tour ------> A simple Log encapsulation for Android, android advanced

Android. util. Log class, which can be easily used to print logs during encoding and debugging. However, if too many logs are printed in the released products, the performance will be seriously affected. Make a simple encapsulation for the android. util. Log class. when the product is to be released, set Debug to false.

The Code is as follows.

Public class LogUtil {/** is set to false when it is officially launched */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 );}}}


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

Author: Ouyang Peng: Welcome to repost. sharing with others is the source of progress!

Reprinted Please retain the original address: http://blog.csdn.net/ouyang_peng

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


Copyright statement: This article is the original author article, welcome to reprint, reprint please indicate the source of http://blog.csdn.net/ouyang_peng

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.