Android TAO Log

Additional

Language
Java
Version
N/A
Created
Feb 8, 2018
Updated
Aug 13, 2018
Owner
Alexandr Tsvetkov (lordtao)
Contributor
Alexandr Tsvetkov (lordtao)
1
Activity
Badge
Generate
Download
Source code
APK file

Commercial

android-tao-log

Tiny, lightweight, informative and very usefull logger for Android. You don't need to define TAG. It is automatically generated and include file name, method, line nuber and of cource the link to the code. Also contains the LongLog class which allows you to print a long messages into the LogCat without limiting the standard output length to less than ~ 4075. See in demo app

Download from Bintray:

Warning! Android Studio 3.1 Logcat prefix not always showing and breaking logger. According to the Google issue tracker it is fixed and is planned for Android Studio 3.2.

Code example:

   Log.v("Verbose");
   Log.d("Debug");
   Log.i("Info");
   Log.e("Error");
   try{
       int i = 10/0;
   } catch (Exception e) {
       Log.e("Some exception", e);
   }
   try{
       int i = 10/0;
   } catch (Exception e) {
       Log.rt("RuntimeException is not handled by Log.rt()", e);
   }

Possibility to outline the log strings (by default). You can also turn off this, just call Log.setLogOutlined(false);

You'll get in your LogCat the lines like below. Clicking on the tag brings you to log into the source code of the class which was caused by the logger:

Activity lifecicle and fragments stack logger

Simple add to your Application class.

ComponentLog.enableComponentsChangesLogging(this);

You will receive information about an activity lifecycle calls

and a changes of the fragments stack

Log interceptor.

Allows use all log information in a custom interceptor. For example intercept and store log in a file.

public class YourInterceptor extends LogInterceptor {

    @Override
    public void log(Level level, String tag, String msg, @Nullable Throwable th) {
      //
    }

}

Add android-tao-log to your project

Android tao log lib is available on Bintray. Please ensure that you are using the latest versions by

Gradle dependency for your Android app:

add to general build.gradle

buildscript {
    repositories {
        jcenter()
        maven {
            url  "http://dl.bintray.com/lordtao/maven"
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
    }
}

allprojects {
    repositories {
        jcenter()
        maven {
            url  "http://dl.bintray.com/lordtao/maven"
        }
    }
}

add to your dependencies in build.gradle

    compile 'ua.at.tsvetkov:taolog:1.4.6@aar'

Changelog

1.4.6 -- Removed @ToLog annotation

  • Removed @ToLog annotation.

1.4.5 -- Log interceptor

  • Added log interceptor.

1.4.4 -- Activity lifecile and fragments stack logging

  • Activity lifecile and fragments stack logging moved to ComponentLog class.
  • Added LongLog for possibility print to LogCat very long messages.

1.4.3 -- Activity lifecile and fragments stack logging

  • Activity lifecile and fragments stack logging updates

1.4.1 -- ToLog annotation

  • added Kotlin classes support;
  • added possibility to align to right new lines in log for AndroidStudio 3.1;
  • combined @ToLog results in/out to one output method.

1.4.0 -- ToLog annotation

  • added support @ToLog annotation;
  • added outline log possibility;