Scribo


Source link: https://github.com/sasneeBlr/scribo

Scribo

A simple easy-to-use debug utility which helps you capture the logs simultaneously to adb terminal as well to a file on SD Card.

Table of Contents

  1. [Gradle Dependency] ( https://github.com/sasneeBlr/scribo#gradle-dependency-jcenter)
  2. [Features] ( https://github.com/sasneeBlr/scribo#features)
  3. [Usage] ( https://github.com/sasneeBlr/scribo#usage)

Gradle Dependency (jCenter)

Easily reference the library in your Android projects using this dependency in your module's build.gradle file:

dependencies {

  compile 'com.sasnee.scribo:scribo:1.2.0' 
}

Features

Scribo allows capturing the debug logs of any android application into a file on external storage in addition to displaying it on the adb terminal. This is ideal to capture logs of the application once it is deployed in the field. The captured logs are stored in the external storage directory under the path: <External Storage>/AppData/<application_name>/
(For eg: /storage/emulated/0/AppData/com.sasnee.scribosample/)

Log Masks

Scribo supports 10 categories of log masks by default. This is useful to categorize logs from individual modules of the application and enable/disable them individually. Scribo also supports setting custom strings to identify these default log categories.
For eg: "UI Module" can be mapped to Category 1, "Display Module" can be mapped to Category 2 and so on. Once this is done, the logs belonging to these categories can be dynamically enabled/disabled.

ADB Logging

Scribo can be configured to disable printing the logs on adb terminal and instead only send it to the file. This might be needed in certain scenarios to enhance performance of the application.

Retrieve Log File

Starting v1.2.0, scribo provides with an option to easily retrieve the log file from the device. This new API can be used to send the log file containing the debug logs to be sent from the device. When this API is invoked, user gets a list of services that can be used to send the log file from the device. (Bluetooth, Email, ShareIT etc). If the intention is to email the log file, scribo exposes an API to prepopulate the list of people to whom the email needs to be sent.


Usage

  • First, initialize scribo by invoking any of the below init() functions:
 DebugHelper.init(Context)  DebugHelper.init(Context, fileName)  DebugHelper.init(Context, fileName, resetFileContents)

Example:

 DebugHelper.init(this);
  // Logs are captured into file "logJournal.txt".  // File contents are reset everytime the application is invoked.
 DebugHelper.init(this, "CapturedLogs.txt");
  // Logs are captured into file "CapturedLogs.txt".  // File contents are reset everytime the application is invoked.
 DebugHelper.init(this, "CapturedLogs.txt", false);

// Logs are captured into file "CapturedLogs.txt".  // File contents are NOT reset everytime the application is invoked.

Please note the init() function needs to be invoked from the main activity of the application.

  • Override the log mask supported by scribo with a custom log mask. (This is optional)
 DebugHelper.mapCustomLogMask(<Default Category>, <Override String>);

Example:

 DebugHelper.mapCustomLogMask(DebugHelper.LOG_CATEGORY_0, "UI Module");

// Map Category 0 to "UI Module"
 DebugHelper.mapCustomLogMask(DebugHelper.LOG_CATEGORY_4, "URL Loader Module");

// Map Category 4 to "URL Loader Module"
  • Enable/Disable the log categories.
 DebugHelper.enableDisableLogCategory(category, isEnable);
 

Example:

 DebugHelper.enableDisableLogCategory(DebugHelper.LOG_CATEGORY_1, true);
  // Enable Category 1 logs.
 DebugHelper.enableDisableLogCategory("UI Module", false);
  // Disable "UI Module" logs.
  • Send log request to scribo
 DebugHelper.logRequest(<TAG>, <Log Message>, <Show on ADB Logs>, <Severity>, <Category>);
  // <TAG> and <Log Message> arguments are mandatory.   // <Show on ADB Logs>, <Severity> and <Category> are optional.   // If <Show on ADB Logs> is not provided, it defaults to true, i.e the log will be shown on ADB terminal.  // If <Severity> is not provided, it defaults to SEVERITY_LEVEL_VERBOSE.  // If <Category> is not provided, it defaults to LOG_CATEGORY_GENERAL.

Example:

 DebugHelper.logRequest(TAG, "Log message");
 DebugHelper.logRequest(TAG, "Log message", false);
  // Do not display this log on the ADB terminal.
 DebugHelper.logRequest(TAG, "Log message", DebugHelper.SEVERITY_LEVEL_ERROR);
 DebugHelper.logRequest(TAG, "Log message", DebugHelper.LOG_CATEGORY_1);
 DebugHelper.logRequest(TAG, "Log message", false, DebugHelper.SEVERITY_LEVEL_WARN, DebugHelper.LOG_CATEGORY_1);
  • Email the log file.
 DebugHelper.sendLogFileByEmail();

  // Do not prepopulate the "To" field of the email. 
  // Enter the email IDs manually before sending the log file.
 DebugHelper.sendLogFileByEmail(List<String> emailList);

  // Prepopulate the "To" field of the email with the list of emailIDs mentioned in emailList.
  // This saves some effort in case the log file is always meant to be sent to same list of people.

Resources

Satellite is a simple (for those who are familiar with RxJava) Android library, which allows to properly connect background tasks with visual parts of an application.

RxT4A - RxJava Toolbox for Android (a fork of RxAndroid).

Power Assert is a language extension which adds extra information when assertions fail. This feature has been invented in Groovy and being spread around other programming languages, and is becoming a fundamental feature for debugging and testing, especially in unit tests: you no longer need to learn a bunch of test matchers such as assertEquals().

This is a ribbonizer as a Gradle plugin for Android, which adds a ribbon to launcher icons.

IconicFontEngine for Android.

A Java code generator for the builder pattern using annotation processing.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes