Reuse build configuration for logger
This commit is contained in:
@@ -65,6 +65,7 @@ android {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
||||||
|
implementation(project(":architecture"))
|
||||||
implementation(project(":database"))
|
implementation(project(":database"))
|
||||||
implementation(project(":datastore"))
|
implementation(project(":datastore"))
|
||||||
implementation(project(":datasource"))
|
implementation(project(":datasource"))
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package gq.kirmanak.mealient
|
|||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import dagger.hilt.android.HiltAndroidApp
|
import dagger.hilt.android.HiltAndroidApp
|
||||||
|
import gq.kirmanak.mealient.architecture.configuration.BuildConfiguration
|
||||||
import gq.kirmanak.mealient.data.analytics.Analytics
|
import gq.kirmanak.mealient.data.analytics.Analytics
|
||||||
import gq.kirmanak.mealient.data.configuration.BuildConfiguration
|
|
||||||
import gq.kirmanak.mealient.logging.Logger
|
import gq.kirmanak.mealient.logging.Logger
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
package gq.kirmanak.mealient.data.configuration
|
|
||||||
|
|
||||||
import gq.kirmanak.mealient.BuildConfig
|
|
||||||
import javax.inject.Inject
|
|
||||||
import javax.inject.Singleton
|
|
||||||
|
|
||||||
@Singleton
|
|
||||||
class BuildConfigurationImpl @Inject constructor() : BuildConfiguration {
|
|
||||||
|
|
||||||
override fun isDebug(): Boolean = BuildConfig.DEBUG
|
|
||||||
}
|
|
||||||
@@ -15,8 +15,6 @@ import dagger.hilt.android.qualifiers.ApplicationContext
|
|||||||
import dagger.hilt.components.SingletonComponent
|
import dagger.hilt.components.SingletonComponent
|
||||||
import gq.kirmanak.mealient.data.analytics.Analytics
|
import gq.kirmanak.mealient.data.analytics.Analytics
|
||||||
import gq.kirmanak.mealient.data.analytics.AnalyticsImpl
|
import gq.kirmanak.mealient.data.analytics.AnalyticsImpl
|
||||||
import gq.kirmanak.mealient.data.configuration.BuildConfiguration
|
|
||||||
import gq.kirmanak.mealient.data.configuration.BuildConfigurationImpl
|
|
||||||
import gq.kirmanak.mealient.data.storage.PreferencesStorage
|
import gq.kirmanak.mealient.data.storage.PreferencesStorage
|
||||||
import gq.kirmanak.mealient.data.storage.PreferencesStorageImpl
|
import gq.kirmanak.mealient.data.storage.PreferencesStorageImpl
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
@@ -46,10 +44,6 @@ interface AppModule {
|
|||||||
@Singleton
|
@Singleton
|
||||||
fun bindPreferencesStorage(preferencesStorage: PreferencesStorageImpl): PreferencesStorage
|
fun bindPreferencesStorage(preferencesStorage: PreferencesStorageImpl): PreferencesStorage
|
||||||
|
|
||||||
@Binds
|
|
||||||
@Singleton
|
|
||||||
fun bindBuildConfiguration(buildConfigurationImpl: BuildConfigurationImpl): BuildConfiguration
|
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
@Singleton
|
@Singleton
|
||||||
fun bindAnalytics(analyticsImpl: AnalyticsImpl): Analytics
|
fun bindAnalytics(analyticsImpl: AnalyticsImpl): Analytics
|
||||||
|
|||||||
14
architecture/build.gradle.kts
Normal file
14
architecture/build.gradle.kts
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
plugins {
|
||||||
|
id("gq.kirmanak.mealient.library")
|
||||||
|
id("dagger.hilt.android.plugin")
|
||||||
|
id("kotlin-kapt")
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
namespace = "gq.kirmanak.mealient.architecture"
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation(libs.google.dagger.hiltAndroid)
|
||||||
|
kapt(libs.google.dagger.hiltCompiler)
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package gq.kirmanak.mealient.architecture
|
||||||
|
|
||||||
|
import dagger.Binds
|
||||||
|
import dagger.Module
|
||||||
|
import dagger.hilt.InstallIn
|
||||||
|
import dagger.hilt.components.SingletonComponent
|
||||||
|
import gq.kirmanak.mealient.architecture.configuration.BuildConfiguration
|
||||||
|
import gq.kirmanak.mealient.architecture.configuration.BuildConfigurationImpl
|
||||||
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@Module
|
||||||
|
@InstallIn(SingletonComponent::class)
|
||||||
|
interface ArchitectureModule {
|
||||||
|
|
||||||
|
@Binds
|
||||||
|
@Singleton
|
||||||
|
fun bindBuildConfiguration(buildConfigurationImpl: BuildConfigurationImpl): BuildConfiguration
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package gq.kirmanak.mealient.data.configuration
|
package gq.kirmanak.mealient.architecture.configuration
|
||||||
|
|
||||||
interface BuildConfiguration {
|
interface BuildConfiguration {
|
||||||
|
|
||||||
fun isDebug(): Boolean
|
fun isDebug(): Boolean
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package gq.kirmanak.mealient.architecture.configuration
|
||||||
|
|
||||||
|
import androidx.viewbinding.BuildConfig
|
||||||
|
import javax.inject.Inject
|
||||||
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
class BuildConfigurationImpl @Inject constructor() : BuildConfiguration {
|
||||||
|
|
||||||
|
@get:JvmName("_isDebug")
|
||||||
|
private val isDebug by lazy { BuildConfig.DEBUG }
|
||||||
|
|
||||||
|
override fun isDebug(): Boolean = isDebug
|
||||||
|
}
|
||||||
@@ -9,6 +9,8 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
implementation(project(":architecture"))
|
||||||
|
|
||||||
implementation(libs.google.dagger.hiltAndroid)
|
implementation(libs.google.dagger.hiltAndroid)
|
||||||
kapt(libs.google.dagger.hiltCompiler)
|
kapt(libs.google.dagger.hiltCompiler)
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,17 @@
|
|||||||
package gq.kirmanak.mealient.logging
|
package gq.kirmanak.mealient.logging
|
||||||
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import gq.kirmanak.mealient.architecture.configuration.BuildConfiguration
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class LogcatAppender @Inject constructor() : Appender {
|
class LogcatAppender @Inject constructor(
|
||||||
|
private val buildConfiguration: BuildConfiguration,
|
||||||
|
) : Appender {
|
||||||
|
|
||||||
private val isLoggable: Boolean by lazy { BuildConfig.DEBUG }
|
private val isLoggable: Boolean
|
||||||
|
get() = buildConfiguration.isDebug()
|
||||||
|
|
||||||
override fun isLoggable(logLevel: LogLevel): Boolean = isLoggable
|
override fun isLoggable(logLevel: LogLevel): Boolean = isLoggable
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ dependencyResolutionManagement {
|
|||||||
rootProject.name = "Mealient"
|
rootProject.name = "Mealient"
|
||||||
|
|
||||||
include(":app")
|
include(":app")
|
||||||
|
include(":architecture")
|
||||||
include(":database")
|
include(":database")
|
||||||
include(":datastore")
|
include(":datastore")
|
||||||
include(":logging")
|
include(":logging")
|
||||||
|
|||||||
Reference in New Issue
Block a user