├── .gitignore ├── .idea ├── codeStyles │ └── codeStyleConfig.xml ├── kotlinc.xml └── vcs.xml ├── README.md ├── build.gradle ├── demo ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── ua │ │ └── at │ │ └── tsvetkov │ │ └── demo │ │ ├── AppTaoLogDemo.java │ │ ├── MainActivity.java │ │ ├── Test.kt │ │ ├── TestFragment.java │ │ └── TestObject.kt │ └── res │ ├── drawable-v24 │ └── ic_launcher_foreground.xml │ ├── drawable │ ├── ic_launcher_background.xml │ └── side_nav_bar.xml │ ├── layout │ ├── activity_main.xml │ ├── app_bar_main.xml │ ├── content_main.xml │ └── nav_header_main.xml │ ├── menu │ └── activity_main_drawer.xml │ ├── mipmap-anydpi-v26 │ ├── ic_launcher.xml │ └── ic_launcher_round.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 │ ├── dimens.xml │ ├── drawables.xml │ ├── strings.xml │ └── styles.xml ├── demokotlin ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── ua │ │ └── at │ │ └── tsvetkov │ │ └── demokotlin │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── ua │ │ │ └── at │ │ │ └── tsvetkov │ │ │ └── demokotlin │ │ │ ├── AppLogDemoKotlin.kt │ │ │ ├── AppTaoLogDemo.kt │ │ │ ├── MainActivity.kt │ │ │ ├── Test.kt │ │ │ ├── TestFragment.kt │ │ │ └── TestObject.kt │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ ├── ic_launcher_background.xml │ │ └── side_nav_bar.xml │ │ ├── layout │ │ ├── activity_main.xml │ │ ├── app_bar_main.xml │ │ ├── content_main.xml │ │ └── nav_header_main.xml │ │ ├── menu │ │ └── activity_main_drawer.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.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 │ │ ├── dimens.xml │ │ ├── drawables.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── ua │ └── at │ └── tsvetkov │ └── demokotlin │ └── ExampleUnitTest.kt ├── gradle.properties ├── gradle └── wrapper │ └── gradle-wrapper.properties ├── img ├── log_activity.png ├── log_arrays.png ├── log_demo.png ├── log_example.png ├── log_fragment.png ├── log_fragments.png ├── log_hex_xml.png ├── log_long.png ├── log_share.png └── log_short.png ├── lib ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── ua │ │ └── at │ │ └── tsvetkov │ │ └── util │ │ └── logger │ │ ├── Log.kt │ │ ├── LogComponents.kt │ │ ├── LogLong.kt │ │ ├── interceptor │ │ ├── Level.kt │ │ ├── LogCatInterceptor.kt │ │ ├── LogInterfaces.kt │ │ ├── LogToFileInterceptor.kt │ │ └── LogToMemoryCacheInterceptor.kt │ │ ├── ui │ │ ├── LogAdapter.kt │ │ ├── LogColor.kt │ │ ├── LogColorSets.kt │ │ ├── LogFragment.kt │ │ └── LogItem.kt │ │ └── utils │ │ ├── Format.kt │ │ ├── FragmentLifecycleLogger.kt │ │ ├── LogFileWorker.kt │ │ └── LogZipper.kt │ └── res │ ├── layout │ ├── fragment_log.xml │ ├── item_log.xml │ ├── item_log_card.xml │ └── log_tool_bar.xml │ └── values │ ├── colors.xml │ ├── log_levels.xml │ └── strings.xml └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Android Studio Navigation editor temp files 30 | .navigation/ 31 | 32 | # Android Studio captures folder 33 | captures/ 34 | 35 | # Intellij 36 | *.iml 37 | .idea/*.* 38 | 39 | # Keystore files 40 | *.jks 41 | 42 | # External native build folder generated in Android Studio 2.2 and later 43 | .externalNativeBuild 44 | 45 | # Google Services (e.g. APIs or Firebase) 46 | google-services.json 47 | 48 | # Freeline 49 | freeline.py 50 | freeline/ 51 | freeline_project_description.json 52 | .idea/markdown-exported-files.xml 53 | .idea/misc.xml 54 | .idea/ 55 | /gradle/wrapper/gradle-wrapper.jar 56 | /gradlew 57 | /gradlew.bat 58 | -------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.idea/kotlinc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | android-tao-log 2 | ================ 3 | 4 | Tiny, lightweight, informative and very useful logger for Android. 5 | New LogCat adaptation for Android Studio Dolphin | 2021.3.1 Patch 1 and higher 6 | You don't need to define TAG. It is automatically generated and include file name, method, line number and of of course the link to the code. 7 | 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. 8 | 9 | [Download the latest release v2.1.1](https://github.com/lordtao/android-tao-log/releases/tag/v2.1.0) 10 | 11 | **Just try the Java or Kotlin** 12 | [Demo apps](https://github.com/lordtao/android-tao-log/releases/tag/v2.1.0) 13 | 14 | ![Image of LogDemo](img/log_demo.png) 15 | 16 | Simple code example 17 | -------------------- 18 | You can see more examples in demo applications. 19 | 20 | ``` 21 | Log.v("Verbose"); 22 | Log.d("Debug"); 23 | Log.i("Info"); 24 | Log.e("Error"); 25 | try{ 26 | int i = 10/0; 27 | } catch (Exception e) { 28 | Log.e("Some exception", e); 29 | } 30 | ``` 31 | 32 | Possibility to outline the log strings (by default). You can also turn off this, just call Log.setLogOutlined(false); 33 | 34 | You'll get in your LogCat the lines like below. 35 | Clicking on the tag brings you to log into the source code of the class which was caused by the logger: 36 | 37 | ![Image of LogCat example](img/log_example.png) 38 | 39 | Easy objects formatting 40 | 41 | ![Image of LogCat example](img/log_hex_xml.png) 42 | 43 | Arrays 44 | ![Image of LogCat example](img/log_arrays.png) 45 | 46 | Long data logger 47 | ---------------- 48 | Sometimes there is a need to display a log of big data. Usual a loggers truncate it. Use LongLog. It will output all data page by page without loss. 49 | 50 | ![Image of LogLong example](img/log_long.png) 51 | 52 | Activity lifecicle and fragments stack logger 53 | --------------------------------------------- 54 | Simple add to your Application class. 55 | ``` 56 | ComponentLog.enableComponentsChangesLogging(this); 57 | ``` 58 | 59 | You will receive information about an activity lifecycle calls 60 | 61 | ![Image of LogActivity example](img/log_activity.png) 62 | 63 | and a changes of the fragments stack 64 | 65 | ![Image of LogFragments example](img/log_fragments.png) 66 | 67 | Log interceptor. 68 | ----------------- 69 | Allows use all log information in a custom interceptor. 70 | See the LogToFileInterceptor which save a log messages to file and you can share the zipped log with help of any external applications, for example by email, google drive and etc. 71 | ``` 72 | public class YourInterceptor extends LogInterceptor { 73 | 74 | @Override 75 | public void log(Level level, String tag, String msg, @Nullable Throwable th) { 76 | // Use this data for save the log to file, send to cloud or etc. 77 | } 78 | 79 | } 80 | ``` 81 | 82 | using: 83 | 84 | ``` 85 | Log.addInterceptor(YourInterceptorImplementation) 86 | ``` 87 | 88 | It is also possible to choose ready-made 89 | LogToFileInterceptor and LogToMemoryCacheInterceptor 90 | 91 | Log fragment 92 | ------------ 93 | Allows to use the simple library snippet to display the application log, record, share, filter 94 | ``` 95 | val logFragment = LogFragment() 96 | supportFragmentManager.beginTransaction().add(R.id.frameContent, logFragment).commit() 97 | ``` 98 | 99 | ![Image of LogFragment example](img/log_fragment.png) 100 | 101 | Zip and share you log 102 | --------------------- 103 | Simple usage - Init at start logging 104 | ``` 105 | LogToFileInterceptor.init(context) 106 | ``` 107 | Prepare and run zipper 108 | ``` 109 | logZipper = LogZipper(LogToFileInterceptor.getSharedInstance(context)) 110 | logZipper.shareZip(activity) 111 | ``` 112 | ![Image of Log Share example](img/log_share.png) 113 | 114 | Add android-tao-log to your project 115 | ----------------------------------- 116 | Android tao log lib is available for direct download (unfortunately Bintray has been deprecated ). 117 | Please ensure that you are using the [latest releases](https://github.com/lordtao/android-tao-log/releases) 118 | 119 | Put downloaded taolog-*.aar file in to the 'lib' directory in your app module and add Gradle dependency: 120 | 121 | ``` 122 | implementation fileTree(dir: "libs", include: ["*.jar", "*.aar"]) 123 | implementation files('libs/taolog-*.aar') 124 | ``` 125 | 126 | Changelog 127 | --------- 128 | 129 | #### 2.1.0 -- New LogCat adaptation 130 | * New LogCat adaptation for Android Studio Dolphin | 2021.3.1 Patch 1 and higher 131 | 132 | #### 2.0.2 -- Minor update 133 | * Added listW, listE, listV, listE methods 134 | 135 | #### 2.0.1 -- Fixes 136 | * Refactoring 137 | 138 | #### 2.0.0 -- Migration to Kotlin. LogFragment 139 | * Migration to Kotlin 140 | * Refactoring 141 | * Fixed LogToFileInterceptor 142 | * Added LogToMemoryCacheInterceptor 143 | * Added LogFragment 144 | * Added Log Zipper / Sharing 145 | 146 | #### 1.4.10 -- Fixed throwable doubles info 147 | * Fixed throwable doubles info 148 | 149 | #### 1.4.8 -- removed annotations 150 | * removed annotations for backward compatibility 151 | 152 | #### 1.4.7 -- added ToFileInterceptor 153 | * added ToFileInterceptor 154 | 155 | #### 1.4.6 -- Removed @ToLog annotation 156 | * Removed @ToLog annotation. 157 | 158 | #### 1.4.5 -- Log interceptor 159 | * Added log interceptor. 160 | 161 | #### 1.4.4 -- Activity lifecile and fragments stack logging 162 | * Activity lifecile and fragments stack logging moved to ComponentLog class. 163 | * Added LongLog for possibility print to LogCat very long messages. 164 | 165 | #### 1.4.3 -- Activity lifecile and fragments stack logging 166 | * Activity lifecile and fragments stack logging updates 167 | 168 | #### 1.4.1 -- ToLog annotation 169 | * added Kotlin classes support; 170 | * added possibility to align to right new lines in log for AndroidStudio 3.1; 171 | * combined @ToLog results in/out to one output method. 172 | 173 | #### 1.4.0 -- ToLog annotation 174 | * added support @ToLog annotation; 175 | * added outline log possibility; 176 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | ext { 2 | buildToolsVersion = '30.0.0' 3 | minSdkVersion = 14 4 | targetSdkVersion = 30 5 | compileSdkVersion = 30 6 | versionMajor = 2 7 | versionMinor = 1 8 | versionPatch = 0 9 | versionName = "${versionMajor}.${versionMinor}.${versionPatch}" 10 | versionCode = versionMajor * 10000 + versionMinor * 100 + versionPatch 11 | gitSha = 'git rev-parse --short HEAD'.execute([], project.rootDir).text.trim() 12 | } 13 | buildscript { 14 | ext.kotlin_version = '1.4.32' 15 | ext.dokka_version = '1.4.0-rc' 16 | 17 | repositories { 18 | google() 19 | jcenter() 20 | mavenCentral() 21 | } 22 | dependencies { 23 | classpath 'com.android.tools.build:gradle:4.1.3' 24 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 25 | classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version" 26 | classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' 27 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5' 28 | } 29 | 30 | } 31 | 32 | allprojects { 33 | repositories { 34 | google() 35 | jcenter() 36 | mavenCentral() 37 | } 38 | tasks.withType(Javadoc) { 39 | enabled = false 40 | } 41 | } 42 | 43 | task clean(type: Delete) { 44 | delete rootProject.buildDir 45 | } 46 | -------------------------------------------------------------------------------- /demo/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /demo/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'kotlin-android' 3 | apply plugin: 'kotlin-android-extensions' 4 | 5 | android { 6 | compileSdkVersion rootProject.compileSdkVersion 7 | buildToolsVersion rootProject.buildToolsVersion 8 | 9 | defaultConfig { 10 | applicationId "ua.at.tsvetkov.demo" 11 | minSdkVersion rootProject.minSdkVersion 12 | targetSdkVersion rootProject.targetSdkVersion 13 | versionName rootProject.versionName 14 | versionCode rootProject.versionCode 15 | buildConfigField "String", "GIT_SHA", "\"${gitSha}\"" 16 | } 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | compileOptions { 24 | sourceCompatibility JavaVersion.VERSION_1_8 25 | targetCompatibility JavaVersion.VERSION_1_8 26 | } 27 | lintOptions { 28 | abortOnError false 29 | } 30 | } 31 | 32 | dependencies { 33 | implementation fileTree(include: ['*.jar'], dir: 'libs') 34 | implementation project(path: ':lib') 35 | implementation 'androidx.appcompat:appcompat:1.2.0' 36 | implementation 'androidx.constraintlayout:constraintlayout:2.0.4' 37 | implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 38 | implementation 'androidx.legacy:legacy-support-v4:1.0.0' 39 | implementation 'com.google.android.material:material:1.2.1' 40 | implementation 'androidx.navigation:navigation-fragment-ktx:2.3.2' 41 | implementation 'androidx.navigation:navigation-ui-ktx:2.3.2' 42 | implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' 43 | } 44 | -------------------------------------------------------------------------------- /demo/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /demo/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 13 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /demo/src/main/java/ua/at/tsvetkov/demo/AppTaoLogDemo.java: -------------------------------------------------------------------------------- 1 | package ua.at.tsvetkov.demo; 2 | 3 | import android.app.Application; 4 | 5 | import ua.at.tsvetkov.util.logger.LogComponents; 6 | import ua.at.tsvetkov.util.logger.Log; 7 | 8 | /** 9 | * Created by lordtao on 06.12.2017. 10 | */ 11 | 12 | public class AppTaoLogDemo extends Application { 13 | 14 | @Override 15 | public void onCreate() { 16 | super.onCreate(); 17 | 18 | if (BuildConfig.DEBUG){ 19 | LogComponents.enableComponentsChangesLogging(this); 20 | } else { 21 | Log.setDisabled(); 22 | } 23 | 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /demo/src/main/java/ua/at/tsvetkov/demo/MainActivity.java: -------------------------------------------------------------------------------- 1 | package ua.at.tsvetkov.demo; 2 | 3 | import android.annotation.SuppressLint; 4 | import android.os.Bundle; 5 | import android.view.MenuItem; 6 | 7 | import com.google.android.material.navigation.NavigationView; 8 | 9 | import java.util.ArrayList; 10 | import java.util.HashMap; 11 | import java.util.Map; 12 | import java.util.Random; 13 | 14 | import androidx.annotation.NonNull; 15 | import androidx.appcompat.app.ActionBarDrawerToggle; 16 | import androidx.appcompat.app.AppCompatActivity; 17 | import androidx.appcompat.widget.Toolbar; 18 | import androidx.core.view.GravityCompat; 19 | import androidx.drawerlayout.widget.DrawerLayout; 20 | import ua.at.tsvetkov.util.logger.Log; 21 | import ua.at.tsvetkov.util.logger.LogLong; 22 | import ua.at.tsvetkov.util.logger.interceptor.Level; 23 | import ua.at.tsvetkov.util.logger.ui.LogFragment; 24 | 25 | public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener { 26 | 27 | private static final String MSG = "TEST MESSAGE\nLINE 1\nLINE 2\nLINE 3"; 28 | private static final String SHORT_MSG = "TEST MESSAGE"; 29 | private static final String LONG_MSG = "TEST MESSAGE\nLINE 1\nLINE 2\nLINE 3" + 30 | "\n a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message 1" + 31 | "\n a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message 2" + 32 | "\n a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message 3" + 33 | "\n a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message 4" + 34 | "\n a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message 5" + 35 | "\n a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message 6" + 36 | "\n a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message 7" + 37 | "\n a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message 8" + 38 | "\n a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message 9" + 39 | "\n a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message 10" + 40 | "\n a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message 11" + 41 | "\n a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message 12" + 42 | "\n a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message 13" + 43 | "\n a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message 14" + 44 | "\n a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message 15" + 45 | "\n a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message 16" + 46 | "\n a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message 17" + 47 | "\n a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message 18" + 48 | "\n a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message 19" + 49 | "\n a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message 20" + 50 | "\n a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message 21" + 51 | "\n a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message 22" + 52 | "\n a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message 23" + 53 | "\n a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message 24" + 54 | "\n a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message 25" + 55 | "\n a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message 26" + 56 | "\n a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message 27" + 57 | "\n a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message 28" + 58 | "\n a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message 29" + 59 | "\n a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message a message 30"; 60 | private TestObject testObject = new TestObject("A Test Object"); 61 | private ActionBarDrawerToggle toggle; 62 | private DrawerLayout drawer; 63 | private NavigationView navigationView; 64 | private LogFragment logFragment; 65 | 66 | @Override 67 | protected void onCreate(Bundle savedInstanceState) { 68 | super.onCreate(savedInstanceState); 69 | setContentView(R.layout.activity_main); 70 | Toolbar toolbar = findViewById(R.id.toolbar); 71 | setSupportActionBar(toolbar); 72 | 73 | drawer = findViewById(R.id.drawer_layout); 74 | navigationView = findViewById(R.id.nav_view); 75 | toggle = new ActionBarDrawerToggle( 76 | this, 77 | drawer, 78 | toolbar, 79 | R.string.navigation_drawer_open, 80 | R.string.navigation_drawer_close 81 | ); 82 | drawer.addDrawerListener(toggle); 83 | toggle.syncState(); 84 | 85 | navigationView.setNavigationItemSelectedListener(this); 86 | 87 | logFragment = new LogFragment(); 88 | getSupportFragmentManager().beginTransaction().add(R.id.frameContent, logFragment).commit(); 89 | } 90 | 91 | @Override 92 | public void onBackPressed() { 93 | if (drawer.isDrawerOpen(GravityCompat.START)) { 94 | drawer.closeDrawer(GravityCompat.START); 95 | } else { 96 | super.onBackPressed(); 97 | } 98 | } 99 | 100 | @SuppressLint("NonConstantResourceId") 101 | @Override 102 | public boolean onNavigationItemSelected(@NonNull MenuItem item) { 103 | if (drawer.isDrawerOpen(GravityCompat.START)) { 104 | drawer.closeDrawer(GravityCompat.START); 105 | } 106 | runScope(item); 107 | return true; 108 | } 109 | 110 | private void runScope(@NonNull MenuItem item) { 111 | switch (item.getItemId()) { 112 | case R.id.nav_log_quick: { 113 | runLogQuick(); 114 | break; 115 | } 116 | case R.id.nav_log_common: { 117 | runLogCommons(); 118 | break; 119 | } 120 | case R.id.nav_log_thread: { 121 | runLogThread(); 122 | break; 123 | } 124 | case R.id.nav_log_arrays: { 125 | runLogArrays(); 126 | break; 127 | } 128 | case R.id.nav_log_xml_hex: { 129 | runLogXmlHex(); 130 | break; 131 | } 132 | case R.id.nav_log_objects: { 133 | runLogClassAndObjects(); 134 | break; 135 | } 136 | case R.id.nav_log_long_common: { 137 | runLogLongCommons(); 138 | break; 139 | } 140 | case R.id.nav_log_long_thread: { 141 | runLogLongThread(); 142 | break; 143 | } 144 | case R.id.nav_log_long_arrays: { 145 | runLogLongArrays(); 146 | break; 147 | } 148 | case R.id.nav_log_long_xml_hex: { 149 | runLongLogXmlHex(); 150 | break; 151 | } 152 | } 153 | logFragment.scrollDown(); 154 | } 155 | 156 | private void runLogQuick() { 157 | 158 | Log.v(Level.VERBOSE.name()); 159 | Log.d(Level.DEBUG.name()); 160 | Log.i(Level.INFO.name()); 161 | Log.w(Level.WARNING.name()); 162 | Log.e(Level.ERROR.name()); 163 | Log.wtf(Level.WTF.name()); 164 | 165 | } 166 | 167 | private void runLogCommons() { 168 | 169 | try { 170 | int i = 10 / 0; 171 | } catch (Exception e) { 172 | Log.e("Exception", e); 173 | } 174 | 175 | Exception ex = new Exception("Log Exception"); 176 | 177 | Log.v(ex); 178 | Log.v(MSG); 179 | Log.v(MSG, ex); 180 | 181 | Log.d(ex); 182 | Log.d(MSG); 183 | Log.d(MSG, ex); 184 | 185 | Log.i(ex); 186 | Log.i(MSG); 187 | Log.i(MSG, ex); 188 | 189 | Log.w(ex); 190 | Log.w(MSG); 191 | Log.w(MSG, ex); 192 | 193 | Log.e(ex); 194 | Log.e(MSG); 195 | Log.e(MSG, ex); 196 | 197 | Log.wtf(ex); 198 | Log.wtf(MSG); 199 | Log.wtf(MSG, ex); 200 | 201 | RuntimeException rt = new RuntimeException(); 202 | try { 203 | Log.rt(rt); 204 | } catch (RuntimeException e) { 205 | Log.v("Intercepted", e); 206 | } 207 | try { 208 | Log.rt(MSG, rt); 209 | } catch (RuntimeException e) { 210 | Log.v("Intercepted", e); 211 | } 212 | } 213 | 214 | private void runLogThread() { 215 | Thread th = new Thread("Boo Thread"); 216 | th.start(); 217 | 218 | Exception ex = new Exception("Thread Exception"); 219 | 220 | Log.threadInfo(); 221 | Log.threadInfo(MSG); 222 | Log.threadInfo(ex); 223 | Log.threadInfo(MSG, ex); 224 | Log.threadInfo(th, ex); 225 | 226 | Log.stackTrace(); 227 | Log.stackTraceV(MSG); 228 | Log.stackTraceI(MSG); 229 | Log.stackTraceD(MSG); 230 | Log.stackTraceW(MSG); 231 | Log.stackTraceE(MSG); 232 | Log.stackTraceWTF(MSG); 233 | } 234 | 235 | private void runLogArrays() { 236 | int[] ints = new int[]{472834, 4235, 657, -1728, 0}; 237 | Log.array(ints); 238 | double[] doubles = new double[]{472834, 4235, 657, -1728, 0}; 239 | Log.array(doubles); 240 | long[] longs = new long[]{472834, 4235, 657, -1728, 0}; 241 | Log.array(longs); 242 | float[] floats = new float[]{645.0f, 235, 57, -128, 0}; 243 | Log.array(floats); 244 | boolean[] bools = new boolean[]{true, false, true}; 245 | Log.array(bools); 246 | char[] chars = new char[]{'c', 'h', 'a', 'r', 's'}; 247 | Log.array(chars); 248 | Object[] objects = new Object[]{"String object", new Object(), 'a', new Object(), 's'}; 249 | Log.array(objects); 250 | 251 | Map map = new HashMap<>(); 252 | map.put(1, "First"); 253 | map.put(2, "Second"); 254 | map.put(3, "Third"); 255 | Log.map(map); 256 | 257 | ArrayList list = new ArrayList<>(); 258 | list.add("First"); 259 | list.add("Second"); 260 | list.add("Third"); 261 | Log.list(list); 262 | } 263 | 264 | private void runLogXmlHex() { 265 | byte[] data = new byte[]{5, 65, 23, 34, 32, 12, 45, 35, 66, 120, 100, 93, 31, 111}; 266 | Log.hex(data); 267 | Log.hex(data, 5); 268 | 269 | String xml = "\n" + 270 | "Alex\n" + 271 | "July\n" + 272 | "Reminder\n" + 273 | "Don't forget me this weekend!\n" + 274 | ""; 275 | Log.xml(xml); 276 | Log.xml(xml, 3); 277 | } 278 | 279 | private void runLogClassAndObjects() { 280 | Log.classInfo(testObject); 281 | Log.objectInfo(testObject); 282 | } 283 | 284 | private void runLogLongCommons() { 285 | Exception ex = new Exception(); 286 | 287 | LogLong.v(LONG_MSG); 288 | LogLong.v(LONG_MSG, ex); 289 | 290 | LogLong.d(LONG_MSG); 291 | LogLong.d(LONG_MSG, ex); 292 | 293 | LogLong.i(LONG_MSG); 294 | LogLong.i(LONG_MSG, ex); 295 | 296 | LogLong.w(LONG_MSG); 297 | LogLong.w(LONG_MSG, ex); 298 | 299 | LogLong.e(LONG_MSG); 300 | LogLong.e(LONG_MSG, ex); 301 | 302 | LogLong.wtf(LONG_MSG); 303 | LogLong.wtf(LONG_MSG, ex); 304 | 305 | RuntimeException rt = new RuntimeException(); 306 | try { 307 | LogLong.rt(LONG_MSG, rt); 308 | } catch (RuntimeException e) { 309 | LogLong.v("Intercepted", e); 310 | } 311 | } 312 | 313 | private void runLogLongThread() { 314 | Exception ex = new Exception(); 315 | 316 | Thread th = new Thread(LONG_MSG); 317 | th.start(); 318 | 319 | LogLong.threadInfo(); 320 | LogLong.threadInfo(LONG_MSG); 321 | LogLong.threadInfo(ex); 322 | LogLong.threadInfo(LONG_MSG, ex); 323 | LogLong.threadInfo(th, ex); 324 | 325 | LogLong.stackTrace(); 326 | LogLong.stackTraceV(LONG_MSG); 327 | LogLong.stackTraceI(LONG_MSG); 328 | LogLong.stackTraceD(LONG_MSG); 329 | LogLong.stackTraceW(LONG_MSG); 330 | LogLong.stackTraceE(LONG_MSG); 331 | LogLong.stackTraceWTF(LONG_MSG); 332 | } 333 | 334 | private void runLogLongArrays() { 335 | Random random = new Random(); 336 | 337 | int[] ints = new int[5000]; 338 | for (int i = 0; i < ints.length; i++) { 339 | ints[i] = random.nextInt(); 340 | } 341 | LogLong.array(ints); 342 | 343 | double[] doubles = new double[5000]; 344 | for (int i = 0; i < doubles.length; i++) { 345 | doubles[i] = random.nextDouble(); 346 | } 347 | LogLong.array(doubles); 348 | 349 | long[] longs = new long[5000]; 350 | for (int i = 0; i < longs.length; i++) { 351 | longs[i] = random.nextLong(); 352 | } 353 | LogLong.array(longs); 354 | 355 | float[] floats = new float[5000]; 356 | for (int i = 0; i < floats.length; i++) { 357 | floats[i] = random.nextFloat(); 358 | } 359 | LogLong.array(floats); 360 | 361 | boolean[] bools = new boolean[5000]; 362 | for (int i = 0; i < bools.length; i++) { 363 | bools[i] = random.nextBoolean(); 364 | } 365 | LogLong.array(bools); 366 | char[] chars = new char[5000]; 367 | for (int i = 0; i < chars.length; i++) { 368 | chars[i] = (char) random.nextInt(30); 369 | } 370 | LogLong.array(chars); 371 | 372 | Object[] objects = new Object[1000]; 373 | for (int i = 0; i < objects.length; i++) { 374 | objects[i] = new Object(); 375 | } 376 | LogLong.array(objects); 377 | 378 | Map map = new HashMap<>(); 379 | for (int i = 0; i < 500; i++) { 380 | map.put(i, SHORT_MSG); 381 | } 382 | LogLong.map(map); 383 | 384 | ArrayList list = new ArrayList<>(); 385 | for (int i = 0; i < 500; i++) { 386 | list.add(SHORT_MSG); 387 | } 388 | LogLong.list(list); 389 | } 390 | 391 | private void runLongLogXmlHex() { 392 | Random random = new Random(); 393 | 394 | byte[] data = new byte[5000]; 395 | for (int i = 0; i < data.length; i++) { 396 | data[i] = (byte) random.nextInt(60); 397 | } 398 | LogLong.hex(data); 399 | LogLong.hex(data, 20); 400 | 401 | StringBuilder sb = new StringBuilder("\n"); 402 | for (int i = 0; i < 500; i++) { 403 | sb 404 | .append("Tove") 407 | .append(i) 408 | .append("\n"); 411 | } 412 | sb.append(""); 413 | String xml = sb.toString(); 414 | LogLong.xml(xml); 415 | LogLong.xml(xml, 3); 416 | } 417 | 418 | } -------------------------------------------------------------------------------- /demo/src/main/java/ua/at/tsvetkov/demo/Test.kt: -------------------------------------------------------------------------------- 1 | package ua.at.tsvetkov.demo 2 | 3 | import ua.at.tsvetkov.util.logger.Log 4 | 5 | /** 6 | * Created by Alexandr Tsvetkov on 3/28/2018. 7 | */ 8 | class Test constructor(name: String) { 9 | 10 | private val mName = name 11 | 12 | fun getName(): String { 13 | Log.v("Name=$mName") 14 | return mName 15 | } 16 | 17 | 18 | } -------------------------------------------------------------------------------- /demo/src/main/java/ua/at/tsvetkov/demo/TestFragment.java: -------------------------------------------------------------------------------- 1 | package ua.at.tsvetkov.demo; 2 | 3 | import android.os.Bundle; 4 | import androidx.annotation.Nullable; 5 | import androidx.fragment.app.Fragment; 6 | 7 | /** 8 | * Created by Alexandr Tsvetkov on 09.11.2017. 9 | */ 10 | public class TestFragment extends Fragment { 11 | 12 | @Override 13 | public void onCreate(@Nullable Bundle savedInstanceState) { 14 | super.onCreate(savedInstanceState); 15 | 16 | 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /demo/src/main/java/ua/at/tsvetkov/demo/TestObject.kt: -------------------------------------------------------------------------------- 1 | package ua.at.tsvetkov.demo 2 | 3 | import java.util.* 4 | 5 | /** 6 | * Created by Alexandr Tsvetkov on 10/30/2020. 7 | */ 8 | class TestObject constructor(val name: String) { 9 | 10 | private val mName = name 11 | val mBirthday = Date() 12 | 13 | } -------------------------------------------------------------------------------- /demo/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /demo/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /demo/src/main/res/drawable/side_nav_bar.xml: -------------------------------------------------------------------------------- 1 | 3 | 9 | -------------------------------------------------------------------------------- /demo/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 15 | 16 | 24 | 25 | -------------------------------------------------------------------------------- /demo/src/main/res/layout/app_bar_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /demo/src/main/res/layout/content_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 17 | 18 | -------------------------------------------------------------------------------- /demo/src/main/res/layout/nav_header_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 14 | 15 | 22 | 23 | 29 | 30 | 35 | -------------------------------------------------------------------------------- /demo/src/main/res/menu/activity_main_drawer.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 11 | 14 | 17 | 20 | 23 | 26 | 27 | 28 | 29 | 30 | 31 | 34 | 37 | 40 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /demo/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /demo/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /demo/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lordtao/android-tao-log/c724e045b4a6fd24daf1a2d6f2668de9e42e9088/demo/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lordtao/android-tao-log/c724e045b4a6fd24daf1a2d6f2668de9e42e9088/demo/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /demo/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lordtao/android-tao-log/c724e045b4a6fd24daf1a2d6f2668de9e42e9088/demo/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lordtao/android-tao-log/c724e045b4a6fd24daf1a2d6f2668de9e42e9088/demo/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /demo/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lordtao/android-tao-log/c724e045b4a6fd24daf1a2d6f2668de9e42e9088/demo/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lordtao/android-tao-log/c724e045b4a6fd24daf1a2d6f2668de9e42e9088/demo/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /demo/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lordtao/android-tao-log/c724e045b4a6fd24daf1a2d6f2668de9e42e9088/demo/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lordtao/android-tao-log/c724e045b4a6fd24daf1a2d6f2668de9e42e9088/demo/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /demo/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lordtao/android-tao-log/c724e045b4a6fd24daf1a2d6f2668de9e42e9088/demo/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lordtao/android-tao-log/c724e045b4a6fd24daf1a2d6f2668de9e42e9088/demo/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /demo/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #07970F 6 | 7 | -------------------------------------------------------------------------------- /demo/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 8dp 6 | 176dp 7 | -------------------------------------------------------------------------------- /demo/src/main/res/values/drawables.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /demo/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | android-tao-log-demo 3 | MainActivity 4 | Open navigation drawer 5 | Close navigation drawer 6 | Android Tao Logger Java Demo 7 | https://github.com/lordtao/android-tao-log 8 | Navigation header 9 | 10 | Log methods 11 | Long data log methods 12 | 13 | Quick log show 14 | Log.v … Log.wtf, Log.rt 15 | Threads and stack trace 16 | Arrays, list, map, set 17 | XML, HEX 18 | Class and object info 19 | Long data. Log.v … Log.wtf, Log.rt 20 | Long data. Threads and stack trace 21 | Long data. Arrays, list, map, set 22 | Long data. XML, HEX 23 | 24 | 25 | -------------------------------------------------------------------------------- /demo/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 15 | 16 | 10 | 11 | 15 | 16 |