Git Product home page Git Product logo

hugo's Introduction

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 return values, 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 above logged for free.

@DebugLog
public 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 the compiled class file for any build type. This means you can keep the annotation and check it into source 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 Wharton

Licensed 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.0

Unless required by applicable law or agreed to in writing, software
distributed 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 and
limitations under the License.

hugo's People

Contributors

chrisjenx avatar danielkutik avatar faradaj avatar jakewharton avatar joninvski avatar justinmuller avatar klynch avatar mkuprionis avatar promeg avatar romainpiel avatar saadfarooq avatar untalfranfernandez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hugo's Issues

Add option to also print thread name

This is a feature request.

@DebugLog(printThread=true)
public void someMethod() {
   ...
}

The above syntax will allow printing the id/name of the thread that the method runs on.

Log to 'verbose'

Hi Jake,

Is there any chance I could convince you to send Hugo's output to Log.v rather than Log.d or maybe make it configurable in some way?

I'd love to have the option to do that.

Great work on the lib though - top class, really simple and adds loads of value! I'll definitely keep using it in my apps.

Ben

Special chars should been masked

I have a string like "Sun\n123" I whould like to see that so in the logcat output too and not as two lines.

Here is my "broken" example output:

D/Holder﹕ ⇢ update(pos=1, label="Sun
    123")

Calls not being logged anymore

Hi!

I have been a very happy user of Hugo for the last weeks, but I just realized that Hugo is not logging calls anymore (at least I can't see them in logcat in Android Studio).

I have not done any changes to my build.gradle and I just made sure I'm running "Build variant: Debug".

Does anyone have any clue as to what might be the problem?
Thank you!

Log 'this'

It would be helpful to log 'this' for non-static methods.

Log particular statement Also

Currently we are allowing logging of methods, can we have it same for particular line or variable.
For example:

@log
String check = "some value returned";

Logcat:

someMethodName.check = "some value returned"

Something like this. At few places I wouldn't want whole message to log, just particular line what value are we getting there.

byte[] argument causes ClassCastException

    @DebugLog
    public synchronized void onSuccess(int statusCode, Header[] headers, byte[] binaryData) {
.....
}

This causes the following

12-05 15:27:24.860: E/AndroidRuntime(20699): java.lang.ClassCastException: byte[] cannot be cast to java.lang.Object[]
12-05 15:27:24.860: E/AndroidRuntime(20699):    at hugo.weaving.internal.Hugo.appendObject(Hugo.java:84)
12-05 15:27:24.860: E/AndroidRuntime(20699):    at hugo.weaving.internal.Hugo.pushMethod(Hugo.java:51)
12-05 15:27:24.860: E/AndroidRuntime(20699):    at hugo.weaving.internal.Hugo.ajc$inlineAccessMethod$hugo_weaving_internal_Hugo$hugo_weaving_internal_Hugo$pushMethod(Hugo.java:1)
12-05 15:27:24.860: E/AndroidRuntime(20699):    at hugo.weaving.internal.Hugo.debugAndInstrumentMethod(Hugo.java:24)

`BuilderConstants` failure with Android Studio 0.6, Android Gradle plugin v11

After upgrading Android Studio to 0.6.0, I get the following error when gradle syncs:

java.lang.NoClassDefFoundError: com.android.builder.BuilderConstants
at hugo.weaving.plugin.HugoPlugin$_apply_closure2.class$(HugoPlugin.groovy)
at hugo.weaving.plugin.HugoPlugin$_apply_closure2.$get$$class$com$android$builder$BuilderConstants(HugoPlugin.groovy)
at hugo.weaving.plugin.HugoPlugin$_apply_closure2.doCall(HugoPlugin.groovy:35)
at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:58)

If I comment out apply plugin: 'hugo' the error goes away

Android Studio 0.6 also made me update buildToolsVersion to 19.1.0

Hugo doesn't work in different debuggable buildTypes

I'm trying to use Hugo in different debuggable buildTypes, but it doesn't print anything. Only works with debug. Is it not based on debuggable var?

prod {
    debuggable true
    signingConfig signingConfigs.debug
}
debug {
    debuggable true
    signingConfig signingConfigs.debug
}

Thanks!

Remove + from dependencies

The dependency specified for the gradle build tools is specified as version 0.7+. Dependencies should always specify specific versions not wildcards.

This becomes a problem for me in that our Nexus repo is behind a VPN. About once a day gradle decides to update its + dependencies. If I do not happen to be connected to the VPN what happens is that Android Studio locks up for 3 or 4 minutes trying to update the dependency and you have to either wait or force quit.

The workaround I am using is to add this to buildScript block:

// The purpose of this is to override the transitive dependency from hugo that specifies
// 'com.android.tools.build:gradle:0.7+' which forces accessing the remote repo
configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        if (details.requested.group == 'com.android.tools.build' && details.requested.name == 'gradle') {
            details.useVersion '1.0.0'
        }
    }
}

Plugin with id 'com.jakewharton.hugo' not found

When following the README which states that the plugin is to be applied with:

apply plugin: 'com.jakewharton.hugo'

I end up with Error:(12, 0) Plugin with id 'com.jakewharton.hugo' not found. When I follow hugo's own example it works fine:

apply plugin: 'hugo'

java.lang.UnsupportedClassVersionError: hugo/weaving/internal/Hugo

Running some unit tests that include a class that has @debuglog annotations leads to the following stack trace:

java.lang.UnsupportedClassVersionError: hugo/weaving/internal/Hugo
    at com.mydomain.services.DataService.loadRetailLocationSeedFileIfNeeded(DataService.java:238)
    at com.mydomain.MyApplication.onCreate(MyApplication.java:30)
    at org.robolectric.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:146)
    at org.robolectric.RobolectricTestRunner.setUpApplicationState(RobolectricTestRunner.java:387)
    at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:227)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:177)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:80)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:47)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:69)
    at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:49)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.messaging.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
    at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
    at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:103)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.messaging.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:355)
    at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:695)

This saddens me, but I will deal with it for now by removing a couple of DebugLog statements so I can get on with things. Thought you'd like to know.

Love this thing still! I'd hug it if I could.

Move time in front of output.

If you have a large array of data returned (due to the buffer length of Log) you will sometimes never see the time taken to execute the method.

e.g.

StationsNearYouAdapter﹕ ⇠ getCursorToSortedList = [ABW, ACC, AML, ASN, AYP, AHT, AAP, AON, AMR, ANZ, AGR, APS, ARL, ACT, ASH, AHV, AFS, AHD, AHS, AWM, APG, AUD, AYS, AVP, AYL, BAG, BAB, BDK, BAL, BAD, ZBB, BKG, BMG, BNH, BNS, BNI, BSO, BBL, BAK, BLB, BAY, BCF, BSD, BEC, BKJ, BGM, BLM, BEG, BVD, BEF, BTY, BKM, BRS, BTO, BET, BXY, BXH, BKL, BIC, BIG, BIK, BIS, BKH, BHO, BAW, BLY, BKA, BRG, BNE, BWB, BOP, BXW, BCE, BTR, BTP, BFD, BRE, BWO, BMD, BRX, BCY, BMN, BMS, BSY, BSP, BPK, BKO, BXB, BCV, BNM, BHK, BSH, BXD, BFN, CIR, CAM, CBH, CMD, ZCW, CNN, CPK, CSH, CSB, CBP, CAT, CTF, CFB, CTH, CFH, CFO, CHW, CTN, CTM, CHE, CED, CHM, CLD, CHY, CHN, CSN, CSS, CHL, CHI, CHP, CIT, CHK, CLW, CHH, CTK, CLA, CLP, CLJ, CPT, CLG, CLK, CSD, COO, CDS, CDN, CWN, CRW, CRY, CES, CWH, CRI, CFT, CRH, COH, CRN, CYP, CUF, CUX, DDK, DLJ, DLK, DFD, DAT, DNM, DGC, DMK, DEP, DKG, DPD, DKT, DMS, DRG, DYP, DNG, EAL, EAR, EAD, ELD, ECR, EDW, EFL, EGR, EML, ETL, EBD, EDN, EBR, EBT, EDR, EFF, EGH, EPH, ELE, ESD, ESM, ELS, ELW, EMP, ENC, ENL, ENF, EPS, EPD, ERI, ERH, ESH, EXR, ETC, EWE, EWW, EYN, FCN, FNB, FNN, FNC, FNH, FNR, ZFD, FGT, FEL, FEN, FNY, FPK, FLE, FLT, FOG, FOH, FRT, FML, FLW, FZP, GSN, GTW, GER, GDP, GLM, GIP, GOD, GDN, GOM, GMY, GDH, GPO, GPK, GRV, GRY, GMN, GFD, GNH, GNW, GRP, GLD, GUN, HCB, HKC, HAC, HKW, HDM, HDW, HGG, HAI, HDH, HMP, HMC, HMW, HAN, HDN, HLN, HWM, HWN, HRO, HPD, HRM, HGY, HRY, HRW, HOH, HSL, HTE, HAT, HAP, HYR, HAY, HYS, HHE, HCN, HDL, HAF, HWV, HXX, HML, HEN, HOT, HNH, HER, HFE, HFN, HEV, HIB, HWY, HGM, HIP, HHY, HLB, HYW, HIT, HGR, HOC, HBN, HLM, HMN, HPA, HOK, HOR, HRN, HRH, HSY, HOU, HWW, HOX, HUR, IFI, IFD, IMW, INT, ISL, IVR, KEL, KMP, KMS, KLY, KNL, KNR, KPA, KTH, KTN, KTW, KNT, KWB, KWG, KDB, KBN, KGL, KNG, KND, KBW, KCK, LAD, LAI, LNY, LEA, LHD, LEE, LIH, LES, LBZ, LEN, LET, LEW, LEM, LER, LID, LHS, LFD, LIP, LIS, LTK, LVN, BFR, LBG, CST, CHX, EUS, FST, LOF, KGX, LST, MYB, PAD, LRD, SPX, STP, VIC, WAT, WAE, LNG, LGF, LGJ, LSY, LUT, LTN, MAI, MDB, MDE, MDW, MAL, MNP, MRN, MLW, MAO, MYL, MZH, MEP, MHM, MLF, MIL, MKC, MTC, MIJ, MRS, MOG, MDS, MTL, MOT, MTG, NBA, NBC, NWX, NXG, NEH, NHE, NEM, NSG, NGT, NWE, NBT, NRB, NCM, NDL, NFA, NSH, NWB, NFL, NLT, NUM, NWD, NHD, NUF, OKL, OCK, OLY, OLD, ORP, OTF, OXS, OXT, PDW, PAL, PKT, PMR, PNE, PNW, PHR, PTR, PET, PSE, PLU, PON, PBR, PRR, PRL, PFL, PUR, PUO, PUT, QPW, QRP, QRB, RDT, RNM, RAI, RVB, RLG, RAY, RDG, RDW, REC, RDH, RHM, REI, RMD, RIC, RDD, RID, RBR, RTR, RFD, RMF, ROE, RYN, RYS, RYH, SAF, SNR, SND, SDR, SAW, SRG, SRS, SVK, SVS, SEV, SDE, SFR, SNF, SPB, SHP, SHI, SDC, SEH, SRT, SID, SLV, SGR, SLO, SDA, SOR, SAT, SBM, SCY, SGN, SOH, SOK, SMO, SRU, STO, SOF, STL, SBU, SIA, SOC, SOV, SAC, SAA, SIH, SJS, SAJ, SMT, SMG, SMY, SNS, SMH, SFO, SSD, SST, SPU, SVG, SKM, SKW, SCG, SBP, SOG, SNL, SRA, SFA, STW, STE, SRC, SRH, SOO, SUD, SDH, SUU, SUP, SNG, SNY, SUR, SQE, SUO, SUC, SAY, SWM, SYD, SYH, SYL, TAD, TAP, TAT, TED, THD, TEO, TTH, TBD, TIL, TOL, TON, TOO, TOM, TRI, TUH, TBW, TUR, TWI, TWY, UPM, UPH, UHL, UWL, VXH, VIR, WDO, WAD, WLT, WLC, WHC, WMW, WAL, WAN, WSW, WWR, WNT, WNP, WPE, WAR, WGV, WNH, WTR, WFH, WFJ, WFN, WAS, WMG, WLI, WGC, WLW, WMB, WCX, WND, WBP, WBY, WCY, WDT, WDU, WEA, WEH, WHD, WHP, WHR, WMA, WNW, WRU, WSU, WWI, WCF, WCB, WYB, WHL, WNY, WTN, WHY, WHS, WIC, WIJ, WIM, WBO, WNF, WIH, WNC, WNR, WNS, WTI, WTM, WTY, WOB, WOK, WKM, WOH, WST, WGR, WME, WWA, WWD, WCP, WPL, WR

you get the point :)

Hugo doesn't work with Android gradle plugin 0.10.0

After upgrading to plugin version 0.10.0 the builds stopped working. With --stacktrace it reveals the issue is hugo; removing hugo fixed the problem.

* What went wrong:
Execution failed for task ':trello-app:compileGoogleDebugJava'.
> No such property: runtimeJarList for class: com.android.build.gradle.AppPlugin

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':trello-app:compileGoogleDebugJava'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
    at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:289)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:23)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:86)
    at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:29)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
    at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
    at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:67)
    at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:54)
    at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:166)
    at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:113)
    at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:81)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:64)
    at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
    at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:35)
    at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:45)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:42)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:24)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.StartStopIfBuildAndStop.execute(StartStopIfBuildAndStop.java:33)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.ReturnResult.execute(ReturnResult.java:34)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:71)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:69)
    at org.gradle.util.Swapper.swap(Swapper.java:38)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:69)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:60)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:45)
    at org.gradle.launcher.daemon.server.DaemonStateCoordinator.runCommand(DaemonStateCoordinator.java:186)
    at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy.doBuild(StartBuildOrRespondWithBusy.java:49)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.HandleStop.execute(HandleStop.java:36)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.DaemonHygieneAction.execute(DaemonHygieneAction.java:39)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.CatchAndForwardDaemonFailure.execute(CatchAndForwardDaemonFailure.java:32)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125)
    at org.gradle.launcher.daemon.server.exec.DefaultDaemonCommandExecuter.executeCommand(DefaultDaemonCommandExecuter.java:51)
    at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.handleCommand(DefaultIncomingConnectionHandler.java:155)
    at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.receiveAndHandleCommand(DefaultIncomingConnectionHandler.java:128)
    at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.run(DefaultIncomingConnectionHandler.java:116)
    at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
Caused by: groovy.lang.MissingPropertyException: No such property: runtimeJarList for class: com.android.build.gradle.AppPlugin
    at hugo.weaving.plugin.HugoPlugin$_apply_closure2_closure3.doCall(HugoPlugin.groovy:53)
    at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:502)
    at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:483)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
    ... 66 more

There is any issue to combine hugo and apt?

Hello guys, thank you for this tool!

I 've an issue in my app. My build script is:

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:0.10.+'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.2'
        classpath 'com.jakewharton.hugo:hugo-plugin:1.1.+'
    }
}

apply plugin: 'android-library'
apply plugin: 'android-apt'
apply plugin: 'hugo'

And I annotated my SyncAdapter-do-all-things method like:

    @DebugLog
    public void make(SyncResult syncResult) {
        // ...
    }

But, I haven't see any log in logcat... Any idea about what I'm doing wrong?

Thank you.

Libraries' @DebugLog doesn't work

My project has a number of modules apart from the actual app.
Today I've tried to use Hugo on one of the 'android-library' modules, and nothing is logged when the app module runs.

Project modules:
app (has compile project(':mylibrary'))
mylibrary (has apply plugin: 'hugo')

Already tried to also apply plugin: 'hugo' on the app module, with no luck.

build.gradle apply plugin order is important

Just a note so that you may update your readme.

If i do

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.6.+'
        classpath 'com.jakewharton.hugo:hugo-plugin:1.0.0'

    }
}

apply plugin: 'hugo'
apply plugin: 'android'

Gradle won't compile my app.

If i switch the apply plugin lines then it works :)

java.lang.VerifyError while using @DebugLog anywhere in my app

        dalvikvm  W  VFY: invoke type does not match method type of Lcom/example/MyActivity;.someMethodToLog
                    W  VFY:  rejecting opcode 0x6f at 0x0000
                    W  VFY:  rejected Lcom/example/MyActivity;.access$1000 (Lcom/example/MyActivity;)V
                    W  Verifier rejected class Lcom/example/MyActivity;
                    W  Class init failed in newInstance call (Lcom/example/MyActivity;)
    AndroidRuntime  D  Shutting down VM
          dalvikvm  W  threadid=1: thread exiting with uncaught exception (group=0x417d3898)
    AndroidRuntime  E  FATAL EXCEPTION: main
                    E  java.lang.VerifyError: com/example/MyActivity
                    E      at java.lang.Class.newInstanceImpl(Native Method)
                    E      at java.lang.Class.newInstance(Class.java:1130)
                    E      at android.app.Instrumentation.newActivity(Instrumentation.java:1078)
                    E      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2220)
                    E      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2359)
                    E      at android.app.ActivityThread.access$700(ActivityThread.java:165)
                    E      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1326)
                    E      at android.os.Handler.dispatchMessage(Handler.java:99)
                    E      at android.os.Looper.loop(Looper.java:137)
                    E      at android.app.ActivityThread.main(ActivityThread.java:5455)
                    E      at java.lang.reflect.Method.invokeNative(Native Method)
                    E      at java.lang.reflect.Method.invoke(Method.java:525)
                    E      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)
                    E      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
                    E      at dalvik.system.NativeStart.main(Native Method)

flag methods w/ times > N msec as errors

E.g., during debug, I'd want to be able to flag methods that take "too long", e.g., DB access methods that take over 1sec and if that happens, put a msg in the log at a warning level.
So instead of @debuglog, maybe add "@DebugLogSlug(1000)" for anything that goes over 1sec?

Allow Injection of Logging Implementation (e.g. Add Support for SLF4J)

At the moment Hugo directly connects @debuglog and the Android Log.v.

The main issue with this is you cannot log to a file, multiple destinations or intercept or transform/mask any log messages.

It would be nice if Hugo would allow plugging the users Logger of choice through something like SLF4J.

I note this is somewhat similar to #40 although the purposes are quite different - solving one should solve the other.

Kill example, create test fixtures in the plugin

Now that features are exploding, we need a way to test them for reals for reals. Create some fixtures in the plugin which exercise specific behaviors and then verifies them in some way. How do you verify the behavior of aspects?

Release a version without '+' dependency on android gradle plugin

1.1.0 relies on 0.7.+ of the android gradle plugin.
https://github.com/JakeWharton/hugo/blob/1.1.0/hugo-plugin/build.gradle

As you know the "+", causes gradle to periodically check for new version of the android gradle plugin, which slows things down and doesn't work if you are offline but don't pass --offline.

It looks like master already has the "+" dependency locked to a specific version, but it would be nice to have a release of that. :)

Support for non Android gradle modules

My android project has some pure Java sub-modules.

It would be great to be able to use Hugo with those as well.
This could likely be done by having Hugo log to slf4j-api instead of android.util.Log.

AspectJ exception

I have noticed that Hugo stopped outputting anything in the logcat. At the same time, I got a bunch of aspectJ error logs in my app root folder. I think it has to do with the inner class you usually create when you need parcelables.

Here is basically what the logs say:

org.aspectj.weaver.BCException: Whilst processing type 'Lcom/wannacorp/api/model/VirtualZone$1;' - cannot cast the outer type to a reference type.  Signature=Lcom/wannacorp/api/model/VirtualZone; toString()=com.wannacorp.api.model.VirtualZone
when processing type mungers 
when weaving 
when batch building BuildConfig[null] #Files=0 AopXmls=#0

    at org.aspectj.weaver.AbstractReferenceTypeDelegate.getFormalTypeParametersFromOuterClass(AbstractReferenceTypeDelegate.java:110)
    at org.aspectj.weaver.bcel.BcelObjectType.ensureGenericSignatureUnpacked(BcelObjectType.java:767)
    at org.aspectj.weaver.bcel.BcelObjectType.getSuperclass(BcelObjectType.java:231)
    at org.aspectj.weaver.ReferenceType.getSuperclass(ReferenceType.java:897)
    at org.aspectj.weaver.bcel.BcelWeaver.weaveParentsFor(BcelWeaver.java:1302)
    at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1121)
    at org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter.weaveQueuedEntries(AjPipeliningCompilerAdapter.java:514)
    at org.aspectj.ajdt.internal.compiler.AjPipeliningCompilerAdapter.afterCompiling(AjPipeliningCompilerAdapter.java:375)
    at org.aspectj.ajdt.internal.compiler.CompilerAdapter.ajc$afterReturning$org_aspectj_ajdt_internal_compiler_CompilerAdapter$2$f9cc9ca0(CompilerAdapter.aj:73)
    at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:550)
    at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation(AjBuildManager.java:1031)
    at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performBuild(AjBuildManager.java:272)
    at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBuildManager.java:185)
    at org.aspectj.ajdt.ajc.AjdtCommand.doCommand(AjdtCommand.java:112)
    at org.aspectj.ajdt.ajc.AjdtCommand.runCommand(AjdtCommand.java:60)
    at org.aspectj.tools.ajc.Main.run(Main.java:371)
    at org.aspectj.tools.ajc.Main$run.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
    at hugo.weaving.plugin.HugoPlugin$_apply_closure2_closure3.doCall(HugoPlugin.groovy:55)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
    (... 20 lines more of stack trace) 

And the source code of the class in question:

/**
 * A special zone that contains all spots of a country/zone that are not attached to any subzone within
 * that entity
 *
 * Created by Vincent Mimoun-Prat @ MarvinLabs, 04/07/2014.
 */
public class VirtualZone implements Zone, android.os.Parcelable {

    private Zone parentZone;
    private int spotCount;

    public VirtualZone() {
    }

    public VirtualZone(Zone parentZone, int spotCount) {
        assert (parentZone != null);

        this.parentZone = parentZone;
        this.spotCount = spotCount;
    }

    // =============================================================================================
    // Zone implementation
    // ==

    @Override
    public long getId() {
        return parentZone.getId();
    }

    @Override
    public int getSpotCount() {
        return spotCount;
    }

    @Override
    public Location getSouthWest() {
        return parentZone.getSouthWest();
    }

    @Override
    public Location getNorthEast() {
        return parentZone.getNorthEast();
    }

    @Override
    public String getName() {
        return parentZone.getName();
    }

    @Override
    public String getGeoPath() {
        return parentZone.getGeoPath();
    }

    @Override
    public List<Zone> getSubZones() {
        return Lists.newArrayListWithExpectedSize(0);
    }

    // =============================================================================================
    // Parcelable
    // ==

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeParcelable(this.parentZone, 0);
        dest.writeInt(this.spotCount);
    }

    private VirtualZone(Parcel in) {
        this.parentZone = in.readParcelable(Zone.class.getClassLoader());
        this.spotCount = in.readInt();
    }

    public static final Creator<VirtualZone> CREATOR = new Creator<VirtualZone>() {
        public VirtualZone createFromParcel(Parcel source) {
            return new VirtualZone(source);
        }

        public VirtualZone[] newArray(int size) {
            return new VirtualZone[size];
        }
    };

    // =============================================================================================
    // Accessors
    // ==

    public Zone getParentZone() {
        return parentZone;
    }


    // =============================================================================================
    // Other methods
    // ==

    @Override
    public boolean equals(Object o) {
        if (o == this) {
            return true;
        }

        if (o instanceof VirtualZone) {
            VirtualZone other = (VirtualZone) o;

            if (!Objects.equal(parentZone, other.parentZone)) {
                return false;
            }

            if (spotCount != other.spotCount) {
                return false;
            }

            return true;
        }

        return false;
    }

    @Override
    public String toString() {
        return Objects.toStringHelper(this)
                .add("parentZone", parentZone)
                .add("spotCount", spotCount)
                .toString();
    }
}

Update README.md

The gradle-howto in readme.md is wrong. I needed to do

apply plugin: 'hugo'

instead of the 'com.jakewharton.hugo' line

Is it possible to use Hugo with ADT projects (i.e Eclipse)?

Hi! This is such a fantastic tool. Really, thanks for that. I wonder if it's possible to use it with ADT (Eclipse) though? I know you made it for Android Studio because of gradle etc but do you have any hints or directions on how to get it working with an Android project on Eclipse? Btw this would be labeled a "question" issue, sorry for using the bug tracker for that :-)

Remove Hugo build litter

On a Gradle build and deploy in Android Studio, Hugo creates a new file called ajcore..txt in the root directory of my project everytime. It would be great if this could be placed in a temp folder and cleaned up after each build as opposed to the current location.

DebugLog does not work in library module

Project with multi-module setup (application + library) does not log methods annotated with @debuglog from library module. In application module it works fine.

here is example https://github.com/curilpe/hugo-test

EDIT:

problem is not in hugo but in android gradle plugin because all library modules are release builds regardless of build type of application.

to change it to debug build just put in build file of library module

android {
defaultPublishConfig "debug"
}

Aspect crashes with NoSuchMethodError when put into .jar or .aar

This is not an issue but rather a question.

I am working with AspectJ as well and it all works well and good as long as the @AspectJ class is in my application module. Once I put the @AspectJ aspect class into a library (either .jar or into an android library), it starts crashing with the following exception:

java.lang.NoSuchMethodError: com.xxx.xxx.TraceAspect.aspectOf

I am compiling my aspects via gradle, which looks pretty much what you are having in Hugo:

android.applicationVariants.all { variant ->
    AppPlugin plugin = project.plugins.getPlugin(AppPlugin)
    JavaCompile javaCompile = variant.javaCompile
    javaCompile.doLast {
        String[] args = ["-showWeaveInfo",
                         "-1.5",
                         "-XnoInline",
                         "-inpath", javaCompile.destinationDir.toString(),
                         "-aspectpath", javaCompile.classpath.asPath,
                         "-d", javaCompile.destinationDir.toString(),
                         "-classpath", javaCompile.classpath.asPath,
                         "-bootclasspath", plugin.project.android.bootClasspath.join(File.pathSeparator)]

        MessageHandler handler = new MessageHandler(true);
        new Main().run(args, handler)

        def log = project.logger
        for (IMessage message : handler.getMessages(null, true)) {
            switch (message.getKind()) {
                case IMessage.ABORT:
                case IMessage.ERROR:
                case IMessage.FAIL:
                    log.error message.message, message.thrown
                    break;
                case IMessage.WARNING:
                    log.warn message.message, message.thrown
                    break;
                case IMessage.INFO:
                    log.info message.message, message.thrown
                    break;
                case IMessage.DEBUG:
                    log.debug message.message, message.thrown
                    break;
            }
        }
    }
}

buildscript -> classpath 'org.aspectj:aspectjtools:1.8.1'
dependencies -> compile 'org.aspectj:aspectjrt:1.8.1'

It really puzzles me, since in Hugo it works having the aspect class in the .jar, so I wonder what I am doing wrong here.

I already posted this question somewhere else, and I am really stuck, so I was wondering if you could point me in the right direction. Thanks anyway.

plugin id is 'hugo', not 'com.jakewharton.hugo'

Trying to use your (wonderfull, thank you so much for that) plugin in my app. Wrote this (as per your README.md):

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:0.12.+'
        classpath 'org.robolectric:robolectric-gradle-plugin:0.11.+'
        // The following adds the ability to use @DebugLog on methods
        classpath 'com.jakewharton.hugo:hugo-plugin:1.1.0'
    }
}

allprojects {
    repositories {
        mavenCentral()
    }
}

apply plugin: 'com.android.application'
apply plugin: 'com.jakewharton.hugo'

Got:

Plugin with id 'com.jakewharton.hugo' not found

Changed to

apply plugin: 'hugo'

and it worked perfectly!
So either I'm missing a point here (being a complete groovy/gradle beginner, that's quite possible) or you need to update your README

Grapple API changed

I have imported Hugo into Android Studio and got following error:

Failed to refresh Gradle project 'hugo'
The project is using an unsupported version of the Android Gradle plug-in (0.7.3).
Version 0.9.0 introduced incompatible changes in the build language.
Please read the migration guide to learn how to update your project.
Open migration guide, fix plug-in version and re-import project

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.