-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f7dfcfb
commit 92c2cd9
Showing
6 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
app/src/main/java/com/pereyrarg11/drinks/core/di/logger/DebugModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.pereyrarg11.drinks.core.di.logger | ||
|
||
import com.pereyrarg11.drinks.core.logger.debug.CrashlyticsDebugLoggerFacade | ||
import com.pereyrarg11.drinks.core.logger.debug.DebugLogger | ||
import com.pereyrarg11.drinks.core.logger.debug.DebugLoggerMediator | ||
import com.pereyrarg11.drinks.core.logger.debug.LogcatDebugLoggerFacade | ||
import dagger.Binds | ||
import dagger.Module | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import dagger.multibindings.IntoSet | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
abstract class DebugModule { | ||
@Binds | ||
@IntoSet | ||
abstract fun bindLogcatDebugLoggerFacade( | ||
debugLoggerFacade: LogcatDebugLoggerFacade | ||
): DebugLogger.Facade | ||
|
||
@Binds | ||
@IntoSet | ||
abstract fun bindCrashlyticsDebugLoggerFacade( | ||
debugLoggerFacade: CrashlyticsDebugLoggerFacade | ||
): DebugLogger.Facade | ||
|
||
@Binds | ||
abstract fun bindDebugLogger( | ||
debugLogger: DebugLoggerMediator | ||
): DebugLogger | ||
} |
19 changes: 19 additions & 0 deletions
19
app/src/main/java/com/pereyrarg11/drinks/core/logger/debug/CrashlyticsDebugLoggerFacade.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.pereyrarg11.drinks.core.logger.debug | ||
|
||
import com.google.firebase.crashlytics.FirebaseCrashlytics | ||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
|
||
@Singleton | ||
class CrashlyticsDebugLoggerFacade @Inject constructor( | ||
private val firebaseCrashlytics: FirebaseCrashlytics, | ||
) : DebugLogger.Facade { | ||
|
||
override fun logMessage(tag: String, message: String) { | ||
firebaseCrashlytics.log("$tag: $message") | ||
} | ||
|
||
override fun logMessage(tag: String, messageTemplate: () -> String) { | ||
logMessage(tag, messageTemplate()) | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
app/src/main/java/com/pereyrarg11/drinks/core/logger/debug/DebugLogger.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.pereyrarg11.drinks.core.logger.debug | ||
|
||
interface DebugLogger { | ||
fun logMessage(tag: String, message: String) | ||
|
||
fun logMessage(tag: String, messageTemplate: () -> String) | ||
|
||
interface Facade : DebugLogger | ||
} |
22 changes: 22 additions & 0 deletions
22
app/src/main/java/com/pereyrarg11/drinks/core/logger/debug/DebugLoggerMediator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.pereyrarg11.drinks.core.logger.debug | ||
|
||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
|
||
@Singleton | ||
class DebugLoggerMediator @Inject constructor( | ||
private val facades: Set<@JvmSuppressWildcards DebugLogger.Facade>, | ||
) : DebugLogger { | ||
|
||
override fun logMessage(tag: String, message: String) { | ||
facades.forEach { debugLogger -> | ||
debugLogger.logMessage(tag, message) | ||
} | ||
} | ||
|
||
override fun logMessage(tag: String, messageTemplate: () -> String) { | ||
facades.forEach { debugLogger -> | ||
debugLogger.logMessage(tag, messageTemplate) | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
app/src/main/java/com/pereyrarg11/drinks/core/logger/debug/LogcatDebugLoggerFacade.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.pereyrarg11.drinks.core.logger.debug | ||
|
||
import android.util.Log | ||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
|
||
@Singleton | ||
class LogcatDebugLoggerFacade @Inject constructor() : DebugLogger.Facade { | ||
override fun logMessage(tag: String, message: String) { | ||
Log.d(tag, message) | ||
} | ||
|
||
override fun logMessage(tag: String, messageTemplate: () -> String) { | ||
logMessage(tag, messageTemplate()) | ||
} | ||
} |