• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

hugo: hugo 是注释驱动的方法,用来在调试的时候调用日志记录

原作者: [db:作者] 来自: 网络 收藏 邀请

Hugo

Annotation-triggered method call logging for your debug builds.

As a programmer, you often add log statements to print method calls, their arguments, their returnvalues, and the time it took to execute. This is not a question. Every one of you does this.Shouldn't it be easier?

Simply add @DebugLog to your methods and you will automatically get all of the things listed abovelogged for free.

@DebugLogpublic String getName(String first, String last) {  SystemClock.sleep(15); // Don't ever really do this!  return first + " " + last;}
V/Example: ⇢ getName(first="Jake", last="Wharton")V/Example: ⇠ getName [16ms] = "Jake Wharton"

The logging will only happen in debug builds and the annotation itself is never present in thecompiled class file for any build type. This means you can keep the annotation and check it intosource control. It has zero effect on non-debug builds.

Add it to your project today!

buildscript {  repositories {    mavenCentral()  }  dependencies {    classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1'  }}apply plugin: 'com.android.application'apply plugin: 'com.jakewharton.hugo'

Disable logging temporarily by adding the following:

hugo {  enabled false}

If you want to toggle logging at runtime, use Hugo.setEnabled(true|false)

Local Development

Working on this project? Here's some helpful Gradle tasks:

  • install - Install plugin, runtime, and annotations into local repo.
  • cleanExample - Clean the example project build.
  • assembleExample - Build the example project. Must run install first.
  • installExample - Build and install the example project debug APK onto a device.

License

Copyright 2013 Jake WhartonLicensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.You may obtain a copy of the License at   http://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap