Giter Club home page Giter Club logo

android-investigator's Introduction

Android Investigator

Android Arsenal

A simple tool that can be used to quickly add informative debug logs to the code during investigation without typing much:

@Override
public void onResume() {
    Investigator.log(this);
    ...
}

log:

D/Investigator: [main] [email protected]()

Features

Easy or automatic logging of the followings at the place of the call:

  • the thread name
  • the !! object instance !! (its toString() value)
  • the method name
  • the stacktrace (for custom method depth)
  • variable values conveniently
  • the time elapsed since a start call
  • an extra comment

Motivation

Android Investigator is not intended as a production logging solution but as a handy productivity tool for helping bugfixing and investigation, kept available on the debug classpath (or even commented out in gradle).
Logging the object instance (not just the class) is the extra that it does compared to other logging libraries. I found it useful in many situations (e.g.: configuration changes, fragment transactions, checking DI scopes, checking activity launchmodes).
It is also simple and convenient to use:

More sample usage

D/Tag: [main] [email protected]()								<- Investigator.log(this)

D/Tag: [thread-5] [email protected]() | comment				    	<- Investigator.log(this, "comment")

D/Tag: [main] [email protected]() | age = 32					<- Investigator.log(this, "age", age)

D/Tag: [main] [email protected]()						<- Investigator.log(this, 3);
				at sample.MyAsyncTask.onPostExecute(MyAsyncTask.java:10)
				at android.os.AsyncTask.finish(AsyncTask.java:651)
				at android.os.AsyncTask.-wrap1(AsyncTask.java)

D/Tag: [main] [email protected]() | 0 ms (STOPWATCH STARTED)	<- Investigator.startStopWatch(this);
D/Tag: [main] [email protected]() | 344 ms					<- Investigator.log(this);

Tag, default stacktrace method depth, thread name, and log level are customizable through the fields of the class. (Check out the class itself or the javadoc.)

When is it useful?

It can be most useful when debugging is not effective any more because there are too many checkpoints to step through or there is asynchronicity. Adding a few simple Investigator log calls to checkpoints can provide an overview about the order of the events, the object instances in play, variable values, where the watched method is called from, and on which thread. (I also found myself using it instead of simple debugging, too.)

Note: The log calls complete fast (usually under 1 ms) so they don't distort the normal program flow.

Download

Android Investigator is available in Maven Central.

Get with gradle:

dependencies {
    debugCompile 'com.github.lemonboston:android-investigator:1.0.0'
}

Or, since it is a single java class, it can be grabbed from here and added to the project (possibly under src/debug/java).

License

MIT License - Copyright (c) 2016 Gabor Keszthelyi

android-investigator's People

Stargazers

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

Watchers

 avatar  avatar  avatar

Forkers

amatkivskiy

android-investigator's Issues

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.