YaLog
Simple wrapper for Android Log with automatic level exclusion
Yet Another Log library?
I want a super-simple, drop-in replacement for android.util.Log
that...
- use formatted string or arbitrary comma-separated parameter list.
- does not generate output for tag/levels specified by code.
- has no performance penalties.
- use gradle 4.x
Setup
-
Add JitPack in your root build.gradle at the end of repositories:
repositories { maven { url "https://jitpack.io" } }
-
Add the dependency
dependencies { implementation 'com.github.amarcruz:yalog:{version}' }
Usage
// Import this plugin instead the default android Log
import com.github.amarcruz.yalog.Log;
...
private static final String TAG = "MyTAG";
// The default log level is predefined to ALL, but you can change it with
Log.setLevel(BuildConfig.DEBUG ? Log.DEBUG : Log.WARN);
// and you can override the default level by tag
Log.setLevel(TAG, Log.ALL);
// Use it as the android.util.Log that you know...
Log.v(TAG, "Hello Log");
// With formatted string
Log.v(TAG, "%s %d", "Hello", 2);
// ...or list
Log.v(TAG, "Hello", 3);
// Because the default level restriction, this does not generates output:
Log.v("Tag2", "Hello");