#Logger# Is a simple class wrapping android logger introducing some utilities.
Logger supports all android log levels (VERBOSE, INFO, WARNING, DEBUG, ERROR, WTF) and handles error prone cases such as Exceptions with no message.
![Methods count](https://img.shields.io/badge/Methods count-42-e91e63.svg)
Get it via Gradle
implementation 'it.xabaras.android.logger:Logger:1.3.6'
or Maven
<dependency>
<groupId>it.xabaras.android.logger</groupId>
<artifactId>Logger</artifactId>
<version>1.3.6</version>
<type>pom</type>
</dependency>
Or download the latest JAR and add it to your project's libraries.
Logger is simple to use, you just have to call static methods from the Logger class.
E.g.
try {
// Your code
} catch(Exception e) {
Logger.e("MyTag", e);
}
Logger has three kinds of logging calls so far.
Wrap the usual call to android Log which takes as parameters a tag and a messagge. Usually it gets called like this:
Logger.d(TAG, "You just pressed the Cancel button.");
Take a tag and a Throwable (e.g. Exception) as parameters and log the Throwable message if any
try {
// Your code
} catch(Exception e) {
Logger.e(TAG, e);
}
Take an Object and a Throwable (e.g. Exception) as parameter, use the object class name as tag and log the error message if any
try {
// Your code
} catch(Exception e) {
Logger.e(this, e);
}
Take an Object and a String as parameters, use the object class name as tag and log the message
try {
// Your code
} catch(Exception e) {
Logger.e(this, "We're sorry! An Exception occurred.");
}
You can add the following lines to your app's proguard configuration file to enforce security (avoid adding logging methods to released app):
-assumenosideeffects class it.xabaras.android.logger.Logger {
public static void d(...);
public static void e(...);
public static void i(...);
public static void v(...);
public static void w(...);
public static void wtf(...);
}