The log wrapper in this article came from a project in GitHub, where I forgot. After this package, you can easily see the log of the class name, method name, number of rows and other information.
1 Public classDLog {2 StaticString ClassName;3 StaticString MethodName;4 Static intlinenumber;5 6 PrivateDLog () {7 /*Protect from Instantiations*/8 }9 Ten Public Static Booleanisdebuggable () { One returnBuildconfig.debug; A } - - Private Staticstring Createlog (string log) { the -StringBuffer buffer =NewStringBuffer (); -Buffer.append ("["); - buffer.append (methodName); +Buffer.append (":"); - buffer.append (linenumber); +Buffer.append ("]"); A buffer.append (log); at - returnbuffer.tostring (); - } - - Private Static voidgetmethodnames (stacktraceelement[] selements) { -ClassName = selements[1].getfilename (); inMethodName = selements[1].getmethodname (); -linenumber = selements[1].getlinenumber (); to } + - Public Static voide (String message) { the if(!isdebuggable ()) { * return; $ }Panax Notoginseng -Getmethodnames (Newthrowable (). Getstacktrace ()); the log.e (ClassName, Createlog (message)); + } A the Public Static voidI (String message) { + if(!isdebuggable ()) { - return; $ } $ -Getmethodnames (Newthrowable (). Getstacktrace ()); - log.i (ClassName, Createlog (message)); the } - Wuyi Public Static voidd (String message) { the if(!isdebuggable ()) { - return; Wu } - AboutGetmethodnames (Newthrowable (). Getstacktrace ()); $ log.d (ClassName, Createlog (message)); - } - - Public Static voidV (String message) { A if(!isdebuggable ()) { + return; the } - $Getmethodnames (Newthrowable (). Getstacktrace ()); the log.v (ClassName, Createlog (message)); the } the the Public Static voidW (String message) { - if(!isdebuggable ()) { in return; the } the AboutGetmethodnames (Newthrowable (). Getstacktrace ()); the LOG.W (ClassName, Createlog (message)); the } the + Public Static voidWTF (String message) { - if(!isdebuggable ()) { the return;Bayi } the theGetmethodnames (Newthrowable (). Getstacktrace ()); - log.wtf (ClassName, Createlog (message)); - } the}
Android output Log Wrapper