Code fragment-set your own logger tool class

Source: Internet
Author: User

Set your own logger tool class

  • You can set a one-click switch.
  • You can set a global tag.
  • Relatively simple to use, log. I (TAG, "in testing..."); Replace with logger. I ("in testing ...");

CodeImplementation example:

Package com.com. test; import android. util. log; public class logger {public static final string tag = "myprojectname"; public static Boolean isdebug = false; public static void setdebug (Boolean Debug) {isdebug = debug ;} public static void I (string s) {If (isdebug) return; log. I (TAG, S);} public static void D (string s) {If (isdebug) return; log. D (TAG, S);} public static void E (string s) {If (isdebug) return; log. E (TAG, S);} public static void W (string s) {If (isdebug) return; log. W (TAG, S );}}

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.