Android output Log Wrapper

Source: Internet
Author: User

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

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.