Implement logging module
This commit is contained in:
@@ -4,22 +4,23 @@ import gq.kirmanak.mealient.data.add.AddRecipeDataSource
|
||||
import gq.kirmanak.mealient.data.add.models.AddRecipeRequest
|
||||
import gq.kirmanak.mealient.data.network.ServiceFactory
|
||||
import gq.kirmanak.mealient.extensions.logAndMapErrors
|
||||
import timber.log.Timber
|
||||
import gq.kirmanak.mealient.logging.Logger
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
class AddRecipeDataSourceImpl @Inject constructor(
|
||||
private val addRecipeServiceFactory: ServiceFactory<AddRecipeService>,
|
||||
private val logger: Logger,
|
||||
) : AddRecipeDataSource {
|
||||
|
||||
override suspend fun addRecipe(recipe: AddRecipeRequest): String {
|
||||
Timber.v("addRecipe() called with: recipe = $recipe")
|
||||
logger.v { "addRecipe() called with: recipe = $recipe" }
|
||||
val service = addRecipeServiceFactory.provideService()
|
||||
val response = logAndMapErrors(
|
||||
block = { service.addRecipe(recipe) }, logProvider = { "addRecipe: can't add recipe" }
|
||||
)
|
||||
Timber.v("addRecipe() response = $response")
|
||||
logger.v { "addRecipe() response = $response" }
|
||||
return response
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user