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