Giter Club home page Giter Club logo

loglifecycle's Introduction

⟳ loglifecycle Maven Central

Logs all lifecycle methods of annotated activities, fragments, views, etc. on Android.

###Usage

Inside your build.gradle file, add :

apply plugin: 'loglifecycle'

And now, annotate every Activity you want to see its life cycle logged in logcat :

@LogLifeCycle
public class MainActivity extends Activity {
...
}

You will see something like this in logcat :

> adb logcat | grep ⟳

D/LogLifeCycle( 4640): MainActivity [1384162984] ⟳ onCreate
D/LogLifeCycle( 4640): MainActivity [1384162984] ⟳ onApplyThemeResource
D/LogLifeCycle( 4640): MainActivity [1384162984] ⟳ onWindowAttributesChanged
D/LogLifeCycle( 4640): MainActivity [1384162984] ⟳ onWindowAttributesChanged
D/LogLifeCycle( 4640): MainActivity [1384162984] ⟳ onWindowAttributesChanged
D/LogLifeCycle( 4640): MainActivity [1384162984] ⟳ onContentChanged
D/LogLifeCycle( 4640): MainActivity [1384162984] ⟳ onAttachFragment
D/LogLifeCycle( 4640): MainActivity$MainFragment [1384183528] ⟳ onCreate
D/LogLifeCycle( 4640): MainActivity [1384162984] ⟳ onStart
D/LogLifeCycle( 4640): MainActivity$MainFragment [1384183528] ⟳ onStart
D/LogLifeCycle( 4640): MainActivity [1384162984] ⟳ onTitleChanged
D/LogLifeCycle( 4640): MainActivity [1384162984] ⟳ onPostCreate
D/LogLifeCycle( 4640): MainActivity [1384162984] ⟳ onResume
D/LogLifeCycle( 4640): MainActivity$MainFragment [1384183528] ⟳ onResume
D/LogLifeCycle( 4640): MainActivity [1384162984] ⟳ onPostResume
D/LogLifeCycle( 4640): MainActivity [1384162984] ⟳ onAttachedToWindow
D/LogLifeCycle( 4640): MainActivity [1384162984] ⟳ onWindowFocusChanged

Extra features :

  • release builds won't log anything, indeed the app is not modified at all in release builds.
  • this plugin will add only a few more bytes to your app : log statements, and the annotation class, nothing more.

###Example

You will find an example app using LogLifeCycle in the repo.

###How does it work ?

Thanks to

  • morpheus, byte code weaver for android.
  • AfterBurner, byte code weaving swiss army knife for Android.

Related projects

On the same principle of byte code weaving :

###TODO

  • add tests

CI

Travis Build Coverage Status

License

Copyright (C) 2014 Stéphane NICOLAS

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.

loglifecycle's People

Contributors

stephanenicolas 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

loglifecycle's Issues

Issue on installing it !

Thank for the lib, this seems to be a required one !
However I didn't succeed to runt it.

1/ I get error :
Execution failed for task ':app:transformLogLifeCycleProcessorDebug'.

Could not execute transformation

2/ In the readme, may I suggest to add :

add this dependency to your plugin.gradle (the project one) file :
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.github.stephanenicolas.loglifecycle:loglifecycle-plugin:1.0.3'
}

asm errors?

is the lombok version including the wrong asm version ?

I am getting these errors on link task execution:

org.objectweb.asm.tree.ClassNode has interface org.objectweb.asm.ClassVisitor as a super class

Plugin is not working out of the box

After adding the plugin in my build.gradle:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.github.stephanenicolas.loglifecycle:loglifecycle-plugin:1.0.1'
    }
}

apply plugin: 'loglifecycle'

Building the project I get this exception:

A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:classpath'.
   > Could not find com.android.support:support-v4:19.1.0.
     Required by:
         android:app:unspecified > com.github.stephanenicolas.loglifecycle:loglifecycle-plugin:1.0.1
   > Could not find com.google.android:android:4.4.2_r2.
     Required by:
         android:app:unspecified > com.github.stephanenicolas.loglifecycle:loglifecycle-plugin:1.0.1

Looks like it cannot find the support library and the android sdk dependency.
I suppose it can't find the support library because its own repository isn't taken into account for plugins.

'loglifecycle' not found.

apply plugin:'loglifecycle'

Error:(103, 1) A problem occurred evaluating project ':app'.

Plugin with id 'loglifecycle' not found.

Annotation processor error "Could not execute transformation"

I'm seeing:

What went wrong:
Execution failed for task ':appname:transformLogLifeCycleProcessorAbcDebug'.
> Could not execute transformation

This is with the following top-level build.gradle:

// ..
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.2'
        classpath 'com.github.stephanenicolas.loglifecycle:loglifecycle-plugin:1.0.3'
    }

And apply plugin: 'loglifecycle' added to the app module's build.gradle. Can provide more environment info if needed.

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.