Lumberjack


Source link: https://github.com/MFlisar/Lumberjack

Lumberjack

What does it do?

A simple logger for JackWhartons Timber logging library with following features:

  • defining group of log messages and filter them, even filter them on a per tree base
  • register custom log formatters to automatically format classes in your logs
  • automatically log first n values of lists/arrays (this automatically respects custom log formatters for classes in the collections!)
  • trees for:
    • logging to console (with the ability to add clickable links to the calling line in the calling class)
    • files (one file per day, select between numbered log file names or date based log file names)
    • notification (with filter functionality per group, next/prev log buttons and more...)
    • overlay logging (expandable/collapseable overlay, show errors only, pausing)
  • customise each tree to whatever you want or extend them
  • little utility class to log time and laps

All features are splitted into seperate modules, just include the modules you want to use!

Gradle (via JitPack.io)

  1. add jitpack to your project's build.gradle:
repositories {

  maven {
 url "https://jitpack.io" 
}
 
}
  1. add the compile statement to your module's build.gradle:
dependencies {

  // base module (NECESSARY)  compile 'com.github.MFlisar.Lumberjack:lumberjack-library:2.0.3'
  // modules (OPTIONAL)
  compile 'com.github.MFlisar.Lumberjack:lumberjack-filelogger:2.0.3'
  compile 'com.github.MFlisar.Lumberjack:lumberjack-notification:2.0.3'  debugCompile 'com.github.MFlisar.Lumberjack:lumberjack-overlay:2.0.3'  releaseCompile 'com.github.MFlisar.Lumberjack:lumberjack-overlay-noop:2.0.3'

 // ALTERNATIVELY you can add ALL modules at once like following
  // compile 'com.github.MFlisar:Lumberjack:2.0.3' 
}

Example - LOGGING

The logger is simply used like following:

// this simply logs a message L.d("Simpe log");
 // arrays/lists can simple be logged directly, the formatter will take care of it L.d("Simple array log: %s", new ArrayList<>(Arrays.asList("array value 1", "array value 2")));
 // group your logs, the formatter takes care of printing the groups and you can filter out groups if you want to L.withGroup("Group").d("Simple log in group");
 // a little helper builder to build object - value pairs and print them to the log L.d(L.labeledValueBuilder()
  .addPair("String", "Value")
  .addPair("Integer", 999)
  .addPair("Long", 5L));

Example - OUTPUT

This is what the demo setup will print out (to your file, to the notification, to console, to the overlay). It has pretty printing enabled and prints first 5 values of an array automatically. It as well prints caller class and group combined as tag. The demo shows that

  • arrays are printed automatically
  • custom classes are automatically formatted with the custom formatter you have registered, no matter if the classes are printed inside an array or as a simple value
  • caller class, tags and groups are printed

Example log

[<TEST-GROUP 1> L:65 initLumberjack]: initLumberjack fertig (L.java:65) [<TEST-GROUP 2> L:66 initLumberjack]: LogFiles: [Type=String, Size=1] (L.java:66) [  /data/user/0/com.michaelflisar.lumberjack.demo/files/log_20170301.log ] [MainActivity:30 onCreate]: Main activity created (MainActivity.java:30) [MainActivity:31 onCreate]: Test message 1: This is the first simple test log (MainActivity.java:31) [MainActivity:32 onCreate]: Test error: Test error log (MainActivity.java:32) java.lang.Throwable: ERROR
  at com.michaelflisar.lumberjack.demo.MainActivity.onCreate(MainActivity.java:32)
  at android.app.Activity.performCreate(Activity.java:6876)
  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135)
  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3207)
  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3350)
  at android.app.ActivityThread.access$1100(ActivityThread.java:222)
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1795)
  at android.os.Handler.dispatchMessage(Handler.java:102)
  at android.os.Looper.loop(Looper.java:158)
  at android.app.ActivityThread.main(ActivityThread.java:7229)
  at java.lang.reflect.Method.invoke(Native Method)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
  at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:102) [MainActivity:38 onCreate]: Test array log: [Type=String, Size=2] (MainActivity.java:38) [  array value 1  array value 2 ] [<TEST-GROUP 1> MainActivity:41 onCreate]: Test message in test group (MainActivity.java:41) [<TEST-GROUP 1> MainActivity:42 onCreate]: Test message in test group, value=999 (MainActivity.java:42) [MainActivity:50 onCreate]: Test custom object log: TestClass: [TestLogData says: My x value is 99] (MainActivity.java:50) [MainActivity:51 onCreate]: Test custom object array log: [Type=TestClass, Size=3] (MainActivity.java:51) [  TestLogData says: My x value is 1  TestLogData says: My x value is 2  TestLogData says: My x value is 10 ] [MainActivity:54 onCreate]: String=Value, Integer=999, Long=5 (MainActivity.java:54) 

Usage

The best place to start is the WIKI and the Demo Activity.

Credits

The overlay logger is based on Hannes Dorfmann's DebugOverlay: https://github.com/sockeqwe/debugoverlay

Resources

Shows a DialogFragment with Camera or Gallery options. The user can choose from where provider wants to pick an image.

This is a library which show how to use Woocommerce using OAuth 1.0a "one-legged" authentication(HTTP).

Simpler to use and faster alternative to LocalBroadcastManager.

All the values from the Material Design guidelines defined in resources for Android.

ImagePicker is a library for picking image from the Android Gallery or technically from MediaStore.Image.Media without the hassle.

Goal of this project is to make an image picker that configureable and extendable.

This Android library allows to scan Wifi single or multiple times and get connect the scanned wifi.

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