MyLog - Library
Simple android logger (2017)
Installation
- Add the dependency from jCenter to your app's (not project) build.gradle file:
repositories {
jcenter()
}
dependencies {
compile 'net.alexandroid.utils:mylog:1.1'
}
- Add init line in your application class as shown below:
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
MyLog.init(this);
MyLog.showLogs(BuildConfig.DEBUG);
}
}
- Also don't forget to add: android:name=".MyApplication" at your application tag in AndroidManifest.xml
<application
android:name=".MyApplication"
...>
How I use it
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MyLog.setTag("CUSTOM TAG")
MyLog.d("Empty 1");
MyLog.i("Empty 2");
MyLog.w("Empty 3");
MyLog.e("Empty 4");
}
Stage 1 - Remove logcat headers
First go to Configure Logcat Header:
Uncheck all options and press OK:
Now your logs looks like below:
Stage 2 - Customize logs color scheme
File -> Settings -> Editor -> Colors & Fonts -> Android Logcat
Stage 3 - Library customization
MyLog.setPackageNameVisibility(true);
MyLog.setIsTimeVisible(false);
MyLog.setThreadIdVisibility(true);
License
Copyright 2017 Alexey Korolev 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.