Logger


Source link: https://github.com/orhanobut/logger

Logger

Simple, pretty and powerful logger for android

Setup

Download

compile 'com.orhanobut:logger:2.1.1'

Initialize

Logger.addLogAdapter(new AndroidLogAdapter());

And use

Logger.d("hello");

Output

Options

Logger.d("debug");
 Logger.e("error");
 Logger.w("warning");
 Logger.v("verbose");
 Logger.i("information");
 Logger.wtf("wtf!!!!");

String format arguments are supported

Logger.d("hello %s", "world");

Collections support (only available for debug logs)

Logger.d(MAP);
 Logger.d(SET);
 Logger.d(LIST);
 Logger.d(ARRAY);

Json and Xml support (output will be in debug level)

Logger.json(JSON_CONTENT);
 Logger.xml(XML_CONTENT);

Advanced

FormatStrategy formatStrategy = PrettyFormatStrategy.newBuilder()
.showThreadInfo(false)  // (Optional) Whether to show thread info or not. Default true
.methodCount(0)

// (Optional) How many method line to show. Default 2
.methodOffset(7)

  // (Optional) Hides internal method calls up to offset. Default 5
.logStrategy(customLog) // (Optional) Changes the log strategy to print out. Default LogCat
.tag("My custom tag")
// (Optional) Global tag for every log. Default PRETTY_LOGGER
.build();
  Logger.addLogAdapter(new AndroidLogAdapter(formatStrategy));

Loggable

Log adapters checks whether the log should be printed out or not by checking this function. If you want to disable/hide logs for output, override isLoggable method and put the condition.

Logger.addLogAdapter(new AndroidLogAdapter() {

@Override public boolean isLoggable(int priority, String tag) {

  return BuildConfig.DEBUG;

}
 
}
);

Save logs to the file

//TODO: More information will be added later

Logger.addLogAdapter(new DiskLogAdapter());

Add custom tag to Csv format strategy

FormatStrategy formatStrategy = CsvFormatStrategy.newBuilder()
.tag("custom")
.build();

 Logger.addLogAdapter(new DiskLogAdapter(formatStrategy));

How it works

More

  • Use the filter for a better result. PRETTY_LOGGER or your custom tag
  • Make sure that wrap option is disabled
  • You can also simplify output by changing settings.

  • Timber Integration
// Set methodOffset to 5 in order to hide internal method calls Timber.plant(new Timber.DebugTree() {

@Override protected void log(int priority, String tag, String message, Throwable t) {

  Logger.log(priority, tag, message, t);

}
 
}
);

Breaking changes

  • Initialization is changed. No backward compatibility support. Use Logger.addLogAdapter
  • LogLevel is removed. Use the new isLoggable approach

License

Copyright 2017 Orhan Obut  Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License. You may obtain a copy of the License at
  http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 

Resources

This is a Web Viewer component.

Tint and colorize Android views easily.

Library allows to cache Observables during orientation change. It's useful during HTTP request, which must be performed only once. After onComplete, Observables are automatically removed from cache.

ObservableCacheService is additional layer over ObservableCache, which generate classes with access to Observables in cache.

Utility classes for Okhttp.

Android Ruler number picker.

Customisable menu that could have from 1 to 10 (and more) buttons. Colors, radius, pictograms - everything can be changed. It suits more for center oriented interfaces and screens. For example by tapping on profile avatar you can open additional functions like Edit, Change Photo etc.

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