Skip to content

frost13it/kinfra-logging-logcat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

kinfra-logging-logcat

Straightforward integration of kinfra-logging with Android Logcat.

Installation

Build script:

repositories {
    maven { url 'https://jitpack.io' }
}

dependencies {
    implementation("com.github.frost13it:kinfra-logging-logcat:0.1")
}

Application class:

class MyApplication : Application {
    override fun onCreate() {
        super.onCreate()
        // Should be performed as early as possible
        DefaultLoggerFactory.delegate = LogcatLoggerFactory()
    }
}

Usage

After the installation, just use kinfra-logging as usual:

class MyActivity : Activity() {
    override fun onCreate() {
        ...
        logger.info { "Created" }
    }
    
    companion object {
        private val logger = Logger.currentClass()
    }
}

Execution of this code puts the following message into Logcat:

I/MyActivity: Created

Configuration

A message will be logged only if it is allowed by Log.isLoggable(tag, level).

By default, minimum log level on Android is INFO. To change it, set the property log.tag to the desired level's abbreviation:

adb shell setprop log.tag D

Level of a particular tag can be set via a property log.tag.<tag>, for example:

adb shell setprop log.tag.MyActivity D

Beware that these properties affect all the applications on the device.

About

Integration of kinfra-logging with Android Logcat

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages