Android Notes 20170117-Two

Source: Internet
Author: User

Custom Logging Tools

 Public classLogutil { Public Static Final intVERBOSE = 1;  Public Static Final intDEBUG = 2;  Public Static Final intINFO = 3;  Public Static Final intWARN = 4;  Public Static Final intERROR = 5;  Public Static Final intnothing = 6;  Public Static intLevel =VERBOSE;  Public Static voidV (string tag, string msg) {if(Level <=VERBOSE)        {LOG.V (tag, msg); }    }         Public Static voidd (string tag, string msg) {if(Level <=DEBUG)        {LOG.D (tag, msg); }    }         Public Static voidI (string tag, string msg) {if(Level <=INFO)        {LOG.I (tag, msg); }    }         Public Static voidW (string tag, string msg) {if(Level <=WARN)        {LOG.W (tag, msg); }    }         Public Static voide (string tag, string msg) {if(Level <=ERROR)        {LOG.E (tag, msg); }    }}

In the project, you can use logutil like normal log tools, such as printing a line of debug-level logs to write:
LOGUTIL.D ("TAG", "Debug Log");

Only need to modify the value of the level variable, you can freely control the print behavior of the log, such as the level equal to verbose can be all the logs are printed out, so that levels equal to warn can only print warning above the log, Keep level equal to nothing to shield all logs.

Therefore, in the project development, only need to be in the development phase of the level designated as verbose, when the project is officially on-line when the level is assigned to nothing on it.

Android Notes 20170117-Two

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.