Skip to content
/ lgg Public

Minimal abstraction for logging with Timber and other libraries

Notifications You must be signed in to change notification settings

ericntd/lgg

Repository files navigation

Overview

The logging module allows you to plug and play and start logging with Timber in your modules easily. More importantly, it gives you the flexibility to switch to another logging implementation with ease.

Usage

  1. Copy and paste the logging module into your project
  2. Don't forget to add it to your settings.gradle and app/build.gradle (as a dependencies)
  3. You can use the built-in Lgg without changing anything:

Set it up

class DemoApplication : Application() {
    override fun onCreate() {
        super.onCreate()

        if (BuildConfig.DEBUG) {
            Lgg.setUp(Lgg.Provider.TIMBER)
        }
    }
}

and use it similar to how you use Timber

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        //...
        Lgg.i("logg testing")
    }
}

outputs

2020-07-17 16:51:35.421 17997-17997/app.ericn.loggdemo I/MainActivity: logg testing

Or, alternatively, you could which logging provider to provide and consume with a dependency framework like Dagger

Provision

@Module
class LoggingModule {
    @Singleton
    @Provides
    fun provideLogger() : Logger {
        return TimberLogger
    }
}

Consumption

class MainActivity : AppCompatActivity() {
    @Inject lateinit var logger: Logger
    override fun onCreate(savedInstanceState: Bundle?) {
        //...
        logger.i("logg testing")
    }
}

About

Minimal abstraction for logging with Timber and other libraries

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages