Thanks to visit codestin.com
Credit goes to github.com

Skip to content

A log library specially designed for Kotlin scenarios in Android development.

License

Notifications You must be signed in to change notification settings

Muyangmin/Kotlog

Repository files navigation

Kotlog

A log library specially designed for Kotlin scenarios in Android development. It's inspired by Android-PLog.

This library does not care persistence or encryption; other libraries does this and you can combine usage with them.

Dependency

Using jcenter
	dependencies {
		implementation 'org.mym.kotlog:kotlog:$latest_version'
	}
Using jitPack
	dependencies {
		implementation 'com.github.Muyangmin:Kotlog:$latest_version'
	}

Usage

Initializing

In you Application#onCreate():

    L.install();

If you forget to call install() method, you will receive an Exception at runtime.

Hello World
L.v("Hello World!")

Advanced

Extend L class api

For example to simplify group usage:

fun L.logLifecycle(msg: String?) = d(msg) {
    group = "Lifecycle"
    stackOffset = 1
}
Add Interceptor

There are 2 types of interceptors: appInterceptor and logInterceptor. Both of them are Interceptor interface, but usage is different: appInterceptor only proceed origin log request, while logInterceptor only proceed decorated(e.g. added log tag, or line number) log request.

L.addApplicationInterceptor({ !BuildConfig.DEBUG })
Customize Printers

A builtin DebugPrinter can be used to print to logcat. If you wants another output, just implement Printer interface, add call L.addPrinter(it).

Warning: calling L.v/d/i/w/e/objects() methods is a common bug, it leads to infinite loops.

About

A log library specially designed for Kotlin scenarios in Android development.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages