Simple Logger for Android
GPL-3.0 License
Simple Logger for Android
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
compile 'com.github.afiqiqmal:EzyLogger:1.1.0'
}
<dependency>
<groupId>com.github.afiqiqmal</groupId>
<artifactId>EzyLogger</artifactId>
<version>1.1.0</version>
</dependency>
Init Logger
Use in Activity
public class BaseActivtiy extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//inline initialize
new Logger.Builder(this).setTag("testing").enableLog(true).create();
//short initialize
Logger.init(this); // Optional if you dont use Logger Toast
Logger.initTag(this,"testing"); // default is 'EzyLogger'
Logger.initTag("testing"); // default is 'EzyLogger'
Logger.canShowLog(true); // default is True
}
}
Logger use
//info log
Logger.info(TAG,"message"); // can set TAG here if not using initTag
Logger.info("message");
Logger.info(Object);
Logger.info(Object,Format); // JSON, XML,LIST, MAP, BUNDLE, STRING, INTENT, ARRAY
Logger.debug(...);
Logger.warn(...);
Logger.error(...);
Logger.verbose(...);
Logger.wtf(...);
//EXAMPLE OF USE
List<?> users = new ArrayList<>();
Bundle bundle = new Bundle();
Map<String,?> map = new LinkedHashMap<>();
Intent intent = new Intent();
Logger.info("message");
Logger.info(0);
Logger.info(new String[]{"test","world","hello"});
Logger.info(new int[]{0,1,2,3,4});
Logger.info(true);
Logger.info(users);
Logger.info(bundle);
Logger.info(map);
Logger.info(intent);
Logger.info(JSON_STRING,Format.JSON);
Logger.info(XML_STRING,Format.XML);
Logger.info(users,Format.LIST);
Logger.info(bundle,Format.BUNDLE);
Logger.info(map,Format.MAP);
Logger.info(intent,Format.INTENT);
Logger.info("message",Format.STRING);
Logger.info(new String[]{"array","1","2"},Format.ARRAY);
Use Logger for showing Toast
// Logger.init(this) is needed
Logger.shortToast(MESSAGE);
Logger.longToast(MESSAGE);
Extra Logger if you need to list all the values in SharedPreferences
//init
Logger.init(this) //needed if not init yet
//will log all the prefs in the default Prefs
new Logger.Preference().printAllSharedPref();
//log all the prefs in the selected Prefs
new Logger.Preference().whichPrefDBName(PREF_NAME).printAllSharedPref();
//log the value by the key
new Logger.Preference().printSharedPrefByKey(KEY);
//OR can do like this
Logger.Preference pref = new Logger.Preference();
pref.whichPrefDBName(PREF_NAME);
pref.printAllSharedPref();
pref.printSharedPrefByKey(KEY);
###License