MyLog

Additional

Language
Java
Version
N/A
Created
Oct 31, 2017
Updated
May 2, 2018
Owner
Alexey Korolev (Pulimet)
Contributor
Alexey Korolev (Pulimet)
1
Activity
Badge
Generate
Download
Source code

Promotion

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.2'
}
  • 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", BuildConfig.DEBUG); 
        //       Context,  Tag,   Show logs?
    }
}
  • 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");
}

Release notes

1.2 - Add MyLog.e(String msg, Throwable t) - (by @davidHarush), 2 new constructors

Stage 1 - Remove logcat headers

Usualy logs look like below:

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

Default:

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.