AdvancedAndroidLogger


Source link: https://github.com/alter-ego/advanced-android-logger

#AdvancedAndroidLogger

This library is meant to offer a wrapper around the standard Android Log.x methods in few distinct flavours. It gives you the possibility to have one logger that will use the same logging tag for the whole app and also the ability to quickly change the logging level for the whole app - you can go from debug to release by changing just one constant.

IAndroidLogger

IAndroidLogger is the interface for all the different flavours used in this library. It has two flavours of logging methods (with or without logging tag) and you have the logging tag and logging level getters and setters. The logging methods are bit more explanatory than the regular Android ones (e.g. debug() instead of Log.d()).

NullAndroidLogger

This is the null-version of the IAndroidLogger, used for initializing the logger variables in order to prevent Null Pointer Exception if the logger is called before being instantiated. You can also use it if you want to stop logging altogether in a certain part of the app.

AndroidLogger

This is the standard Log.x implementation of the IAndroidLogger. It has 3 constructors:

  • public AndroidLogger() - instantiates the logger with the LoggingLevel.NORMAL (equates to the Log.i, advised by Google for public releases) and the default logging tag "ADVANCEDANDROIDLOGGER"
  • public AndroidLogger(String tag) - instantiates the logger with the LoggingLevel.NORMAL and a logging tag
  • AndroidLogger(String tag, LoggingLevel level) - instantiates the logger with desired logging level and tag

You can always change the logging level afterwards with setLoggingLevel (LoggingLevel level) and setLoggingLevel (int level) methods. You can override the logging tag by calling methods in the form of verbose (String tag, String content) or use the tag by calling verbose (String content).

DetailedAndroidLogger

This is the enriched Log.x implementation of that prints the class name, method and line number before in front of the regular logging content (e.g. ReaderActivity.logPrinting() @ line 132: ReaderActivity loggerTesting 3). That way you don't have to put the class details in the message manually.

MemoryUsageAndroidLogger

This is the IAndroidLogger decorator that adds current memory info to the beginning of the logging content. It is implemented as a decorator so you can use it with every IAndroidLogger implementation - just pass the reference in the constructor. The constructor public MemoryUsageAndroidLogger(IAndroidLogger logger, MemoryUnit unit) also needs a MemoryUnit which can be Bytes, Kilobytes = KB and Megabytes = MB.

The memory info is in the following format: "Current memory stats RAM used = (totalMemory - freeMemory)/maxAvailableMemory; HEAP used = heapAllocatedMemory FOR regular log message" where: totalMemory = Runtime.getRuntime().totalMemory() freeMemory = Runtime.getRuntime().freeMemory() maxAvailableMemory = Runtime.getRuntime().maxMemory() heapAllocatedMemory = Debug.getNativeHeapAllocatedSize()

MultiLoggerWrapper

This is the IAndroidLogger wrapper that enables you to use multiple loggers at the same time. Just instantiate it, call registerLogger(IAndroidLogger logger) and unregisterLogger(IAndroidLogger logger) to register and unregister already instantiated loggers, and then call regular IAndroidLogger methods like you would normally do.

That way you can not only have multiple loggers (for example, regular AndroidLogger and TestFlight logger implementation) called together, but you can also have multiple loggers set for multiple logging levels. If you want, you can set the same logging level for all of them calling setLoggingLevel methods, but you cannot undo it afterwards (i.e. set different logging levels for different loggers).

DEPENDENCIES

None.

USAGE

Add this new repo to your build.gradle file:

repositories {

  mavenCentral()
  maven {
 url "https://github.com/alter-ego/advanced-android-logger/raw/develop/releases/" 
}
 
}

Add a new dependency:

compile 'com.alterego:advancedandroidlogger:1.0.7@aar'

Create your logger:

DetailedAndroidLogger logger = new DetailedAndroidLogger("YOUR_TAG", IAndroidLogger.LoggingLevel.VERBOSE);

LICENSE

This library is licensed under Apache License, Version 2.0.

Resources

BaseAdapter and RecyclerView.Adapter could be obtained by encapsulating simple and generic Adapter object.

Simplify the detection of faces using the front facing camera.

This project has been built with horizontal view pager which has vertical view pager on each child, so you can swype in X and Y coordinates.

A simple date picker for android.

Easy to use multi-threaded downloader for Android.

Pretty component to show score points with animation.

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