├── .gitignore ├── CHANGELOG.md ├── README.md ├── _config.yml ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── tech │ │ └── saymagic │ │ └── daffodil │ │ └── demo │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── tech │ │ │ └── saymagic │ │ │ └── daffodil │ │ │ └── demo │ │ │ └── MainActivity.java │ └── res │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── tech │ └── saymagic │ └── daffodil │ └── demo │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── lib ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── tech │ │ └── saymagic │ │ └── daffodil │ │ └── lib │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── tech │ │ │ └── saymagic │ │ │ └── daffodil │ │ │ └── lib │ │ │ ├── Daffodil.java │ │ │ ├── DaffodilPrinter.java │ │ │ ├── MethodInfo.java │ │ │ └── MethodRemember.java │ └── res │ │ └── values │ │ └── strings.xml │ └── test │ └── java │ └── tech │ └── saymagic │ └── daffodil │ └── lib │ └── ExampleUnitTest.java ├── plugin ├── .gitignore ├── build.gradle └── src │ └── main │ ├── groovy │ └── tech │ │ └── saymagic │ │ └── daffodil │ │ └── plugin │ │ ├── ClassGuard.groovy │ │ ├── ClassUtils.groovy │ │ ├── Constants.groovy │ │ ├── DaffodilExtension.groovy │ │ ├── DaffodilPlugin.groovy │ │ ├── asm │ │ ├── DaffodilClassVisiter.groovy │ │ └── DaffodilMethodVisitor.groovy │ │ └── transform │ │ └── DaffodilTransform.groovy │ └── resources │ └── META-INF │ └── gradle-plugins │ └── tech.saymagic.daffodil.properties └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea 5 | .DS_Store 6 | /build 7 | /captures 8 | .externalNativeBuild 9 | publishToJcenter.sh 10 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 2017-07-14 2 | Support Library - v1.1.0 3 | 4 | ## 2017-06-17 5 | Init - v1.0.0 6 | 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Daffodil 2 | === 3 | 4 | Daffodil is an Annotation-triggered method call logging library. 5 | 6 | Usage 7 | --------- 8 | 9 | 10 | 1. Add daffodil closure in `build.gradle` 11 | 12 | ``` 13 | 14 | daffodil { 15 | enabled true 16 | } 17 | 18 | ``` 19 | 20 | 2. Add `@ Daffodil` Annotation on methods, method call's detail info will automatically be recorded. 21 | 22 | ``` 23 | @Daffodil 24 | public int max(int a, int b) { 25 | return Math.max(a, b); 26 | } 27 | ``` 28 | 29 | As the method max invoked, log is printed like following: 30 | 31 | ``` 32 | I/MainActivity: max(1607348716,366634143) = 1607348716 {1ms, main} 33 | ``` 34 | 35 | 3. Enable/Disable daffodil in runtime 36 | 37 | ``` 38 | DaffodilPrinter.setEnabled(true/false); 39 | ``` 40 | 41 | 4. Customized printer 42 | 43 | ``` 44 | DaffodilPrinter.setPrintDelegate(new DaffodilPrinter.DaffodilPrinterDelegate() { 45 | @Override 46 | public void printMethod(MethodInfo info) { 47 | 48 | } 49 | 50 | @Override 51 | public void log(String msg) { 52 | 53 | } 54 | }); 55 | ``` 56 | 57 | Download 58 | ---- 59 | 60 | * add the plugin to your top build script: 61 | 62 | ``` 63 | buildscript { 64 | repositories { 65 | jcenter() 66 | } 67 | dependencies { 68 | classpath 'tech.saymagic:daffodil:1.1.0' 69 | } 70 | } 71 | ``` 72 | * apply plugin in your project: 73 | 74 | ``` 75 | apply plugin: 'tech.saymagic.daffodil' 76 | ``` 77 | 78 | * add runtime library in your project's dependencies: 79 | 80 | ``` 81 | dependencies { 82 | compile 'tech.saymagic:daffodil-lib:1.1.0@aar' 83 | } 84 | ``` 85 | 86 | License 87 | -------- 88 | 89 | Copyright 2017 Saymagic 90 | 91 | Licensed under the Apache License, Version 2.0 (the "License"); 92 | you may not use this file except in compliance with the License. 93 | You may obtain a copy of the License at 94 | 95 | http://www.apache.org/licenses/LICENSE-2.0 96 | 97 | Unless required by applicable law or agreed to in writing, software 98 | distributed under the License is distributed on an "AS IS" BASIS, 99 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 100 | See the License for the specific language governing permissions and 101 | limitations under the License. 102 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'tech.saymagic.daffodil' 3 | 4 | android { 5 | compileSdkVersion 25 6 | buildToolsVersion "25.0.2" 7 | defaultConfig { 8 | applicationId "tech.saymagic.daffodil.demo" 9 | minSdkVersion 11 10 | targetSdkVersion 25 11 | versionCode 1 12 | versionName "1.0" 13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 14 | } 15 | buildTypes { 16 | release { 17 | minifyEnabled false 18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 19 | } 20 | } 21 | } 22 | 23 | daffodil { 24 | enabled true 25 | } 26 | 27 | dependencies { 28 | compile fileTree(dir: 'libs', include: ['*.jar']) 29 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 30 | exclude group: 'com.android.support', module: 'support-annotations' 31 | }) 32 | compile 'com.android.support:appcompat-v7:25.3.0' 33 | compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4' 34 | testCompile 'junit:junit:4.12' 35 | compile 'tech.saymagic:daffodil-lib:1.1.0@aar' 36 | 37 | // compile project(":lib") 38 | } 39 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/saymagic/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /app/src/androidTest/java/tech/saymagic/daffodil/demo/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package tech.saymagic.daffodil.demo; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("tech.saymagic.daffodil.demo", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/java/tech/saymagic/daffodil/demo/MainActivity.java: -------------------------------------------------------------------------------- 1 | package tech.saymagic.daffodil.demo; 2 | 3 | import android.support.v7.app.AppCompatActivity; 4 | import android.os.Bundle; 5 | import android.util.Log; 6 | import android.view.View; 7 | import android.widget.Toast; 8 | 9 | import java.util.Random; 10 | 11 | import tech.saymagic.daffodil.lib.Daffodil; 12 | import tech.saymagic.daffodil.lib.DaffodilPrinter; 13 | import tech.saymagic.daffodil.lib.MethodInfo; 14 | import tech.saymagic.daffodil.lib.MethodRemember; 15 | 16 | public class MainActivity extends AppCompatActivity implements View.OnClickListener{ 17 | 18 | @Override 19 | protected void onCreate(Bundle savedInstanceState) { 20 | super.onCreate(savedInstanceState); 21 | setContentView(R.layout.activity_main); 22 | findViewById(R.id.btn_random_max_test).setOnClickListener(this); 23 | } 24 | 25 | @Daffodil 26 | public int max(int a, int b) { 27 | return Math.max(a, b); 28 | } 29 | 30 | @Override 31 | public void onClick(View v) { 32 | int id = v.getId(); 33 | switch (id) { 34 | case R.id.btn_random_max_test: 35 | Random random = new Random(); 36 | boolean enabled = random.nextBoolean(); 37 | DaffodilPrinter.setEnabled(enabled); 38 | Toast.makeText(this, max(random.nextInt(), random.nextInt()) + " " + enabled, Toast.LENGTH_LONG).show(); 39 | break; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 |