Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add logger #116

Merged
merged 7 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ jobs:
gpg -d --passphrase "${{ secrets.KEY_STORE_PASSWORD }}" --batch release.keystore.asc > release.keystore

- name: Generate Release Bundle
run: ./gradlew bundleRelease
run: ./gradlew bundleProductionRelease
env:
SIGNING_KEY_ALIAS: ${{ secrets.ALIAS }}
SIGNING_KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
Expand All @@ -164,13 +164,13 @@ jobs:
uses: actions/upload-artifact@master
with:
name: bundle
path: app/build/outputs/bundle/release/app-release.aab
path: app/build/outputs/bundle/productionRelease/app-production-release.aab

- name: Upload mapping.txt
uses: actions/upload-artifact@master
with:
name: mapping.txt
path: app/build/outputs/mapping/release/mapping.txt
path: app/build/outputs/mapping/productionRelease/mapping.txt

deploy-play-store:
needs: [ build ]
Expand Down
42 changes: 18 additions & 24 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import com.costular.atomtasks.Versioning

plugins {
id("atomtasks.android.application")
kotlin("kapt")
Expand All @@ -15,8 +17,8 @@ android {

defaultConfig {
applicationId = "com.costular.atomtasks"
versionCode = 11
versionName = "2.1.0"
versionCode = Versioning.VersionCode
versionName = Versioning.VersionName
testInstrumentationRunner = "com.costular.atomtasks.core.testing.AtomTestRunner"

javaCompileOptions {
Expand All @@ -36,8 +38,18 @@ android {
}
}

testOptions {
unitTests {
isIncludeAndroidResources = true
}
}

buildFeatures {
buildConfig = true
}

signingConfigs {
create("release") {
create("production") {
storeFile = rootProject.file("release.keystore")
storePassword = System.getenv("SIGNING_STORE_PASSWORD")
keyAlias = System.getenv("SIGNING_KEY_ALIAS")
Expand All @@ -46,26 +58,8 @@ android {
}

buildTypes {
getByName("release") {
isMinifyEnabled = true
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
signingConfig = signingConfigs.getByName("release")
}
getByName("debug") {
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
}
}

packagingOptions {
resources.excludes.add("META-INF/licenses/**")
resources.excludes.add("META-INF/AL2.0")
resources.excludes.add("META-INF/LGPL2.1")
}

testOptions {
unitTests {
isIncludeAndroidResources = true
release {
signingConfig = signingConfigs.getByName("production")
}
}
}
Expand All @@ -84,6 +78,7 @@ dependencies {
implementation(project(":core:ui"))
implementation(project(":core:designsystem"))
implementation(projects.core.notifications)
implementation(projects.core.logging)
implementation(project(":data"))
implementation(project(":feature:agenda"))
implementation(project(":feature:createtask"))
Expand All @@ -103,7 +98,6 @@ dependencies {
implementation(libs.appcompat)
implementation(libs.lifecycle.compose)
implementation(libs.viewmodel)
implementation(libs.timber)
implementation(libs.hilt)
kapt(libs.hilt.compiler)
implementation(libs.hilt.work)
Expand Down
10 changes: 0 additions & 10 deletions app/src/debug/kotlin/com/costular/atomtasks/Logger.kt

This file was deleted.

19 changes: 17 additions & 2 deletions app/src/main/java/com/costular/atomtasks/ui/AtomTasksApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ import android.app.Application
import android.util.Log
import androidx.hilt.work.HiltWorkerFactory
import androidx.work.Configuration
import com.costular.atomtasks.Logger
import com.costular.atomtasks.BuildConfig
import com.costular.atomtasks.core.logging.AtomLogger
import com.costular.atomtasks.core.logging.FirebaseAtomLogger
import com.costular.atomtasks.core.logging.LogcatAtomLogger
import com.costular.atomtasks.tasks.manager.AutoforwardManager
import com.google.firebase.crashlytics.ktx.crashlytics
import com.google.firebase.ktx.Firebase
import dagger.hilt.android.HiltAndroidApp
import javax.inject.Inject

Expand All @@ -24,7 +29,17 @@ class AtomTasksApp : Application(), Configuration.Provider {
}

private fun init() {
Logger.invoke(this)
initLogger()
}

private fun initLogger() {
val logger = if (BuildConfig.DEBUG) {
LogcatAtomLogger()
} else {
FirebaseAtomLogger(Firebase.crashlytics)
}

AtomLogger.initialize(logger)
}

override fun getWorkManagerConfiguration() =
Expand Down
9 changes: 0 additions & 9 deletions app/src/release/kotlin/com/costular/atomtasks/Logger.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import com.android.build.gradle.internal.dsl.BaseAppModuleExtension
import com.costular.atomtasks.configureAndroidCompose
import com.costular.atomtasks.configureBuildTypes
import com.costular.atomtasks.configureFlavors
import com.costular.atomtasks.configureKotlinAndroid
import org.gradle.api.Plugin
import org.gradle.api.Project
Expand All @@ -15,6 +17,8 @@ class AndroidApplicationConventionPlugin : Plugin<Project> {

extensions.configure<BaseAppModuleExtension> {
configureKotlinAndroid(this)
configureFlavors(this)
configureBuildTypes(this)
configureAndroidCompose(this)
defaultConfig.targetSdk = 34
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package com.costular.atomtasks

import com.android.build.api.dsl.ApplicationExtension
import com.android.build.api.dsl.ApplicationProductFlavor
import com.android.build.api.dsl.CommonExtension
import com.android.build.gradle.internal.dsl.BaseAppModuleExtension

enum class FlavorDimension(
val naming: String
) {
Environment("environment")
}

enum class Flavor(
val naming: String,
val dimension: FlavorDimension,
val applicationIdSuffix: String? = null,
) {
Development("development", FlavorDimension.Environment, applicationIdSuffix = ".dev"),
Production("production", FlavorDimension.Environment)
}

fun configureFlavors(commonExtensions: CommonExtension<*, *, *, *, *>) {
commonExtensions.apply {
flavorDimensions += FlavorDimension.Environment.naming
productFlavors {
Flavor.values().forEach { flavor ->
create(flavor.naming) {
dimension = flavor.dimension.naming
if (this@apply is ApplicationExtension && this is ApplicationProductFlavor) {
flavor.applicationIdSuffix?.let {
applicationIdSuffix = it
}
}
}
}
}
}
}

fun configureBuildTypes(baseAppModuleExtension: BaseAppModuleExtension) {
with (baseAppModuleExtension) {
buildTypes {
getByName("release") {
isDebuggable = false
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
}
getByName("debug") {
isDebuggable = true
isMinifyEnabled = false
isShrinkResources = false
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.costular.atomtasks

object Versioning {
const val VersionCode = 11
const val VersionName = "2.1.0"
}
2 changes: 1 addition & 1 deletion common/tasks/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ dependencies {
implementation(projects.core.analytics)
implementation(projects.data)
implementation(projects.core.notifications)
implementation(projects.core.logging)

implementation(libs.compose.activity)
implementation(libs.compose.foundation)
Expand All @@ -38,7 +39,6 @@ dependencies {
implementation(libs.hilt.navigation.compose)
implementation(libs.hilt.work)
implementation(libs.work)
implementation(libs.timber)
implementation(libs.compose.destinations)
implementation(libs.accompanist.permissions)
kapt(libs.hilt.ext.compiler)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.costular.atomtasks.tasks.interactor

import com.costular.atomtasks.core.logging.atomLog
import com.costular.atomtasks.tasks.manager.TaskReminderManager
import com.costular.core.Either
import com.costular.core.toError
Expand Down Expand Up @@ -45,6 +46,7 @@ class PostponeTaskUseCase @Inject constructor(
)
Unit.toResult()
} catch (e: Exception) {
atomLog { e }
PostponeTaskFailure.Unknown.toError()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import androidx.work.CoroutineWorker
import androidx.work.PeriodicWorkRequest
import androidx.work.PeriodicWorkRequestBuilder
import androidx.work.WorkerParameters
import com.costular.atomtasks.core.logging.atomLog
import com.costular.atomtasks.tasks.interactor.AutoforwardTasksUseCase
import dagger.assisted.Assisted
import dagger.assisted.AssistedInject
Expand All @@ -25,6 +26,7 @@ class AutoforwardTasksWorker @AssistedInject constructor(
autoforwardTasksUseCase(AutoforwardTasksUseCase.Params(LocalDate.now()))
Result.success()
} catch (e: Exception) {
atomLog { e }
Result.failure()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.Context
import androidx.hilt.work.HiltWorker
import androidx.work.CoroutineWorker
import androidx.work.WorkerParameters
import com.costular.atomtasks.core.logging.atomLog
import com.costular.atomtasks.notifications.TaskNotificationManager
import com.costular.atomtasks.tasks.interactor.UpdateTaskIsDoneInteractor
import dagger.assisted.Assisted
Expand Down Expand Up @@ -36,6 +37,7 @@ class MarkTaskAsDoneWorker @AssistedInject constructor(

Result.success()
} catch (e: Exception) {
atomLog { e }
Result.failure()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import android.content.Context
import androidx.hilt.work.HiltWorker
import androidx.work.CoroutineWorker
import androidx.work.WorkerParameters
import com.costular.atomtasks.core.logging.atomLog
import com.costular.atomtasks.notifications.TaskNotificationManager
import com.costular.atomtasks.tasks.interactor.GetTaskByIdInteractor
import dagger.assisted.Assisted
import dagger.assisted.AssistedInject
import kotlinx.coroutines.flow.first
import timber.log.Timber

@Suppress("TooGenericExceptionCaught", "SwallowedException")
@HiltWorker
Expand Down Expand Up @@ -48,7 +48,7 @@ class NotifyTaskWorker @AssistedInject constructor(
taskNotificationManager.remindTask(task.id, task.name)
Result.success()
} catch (e: Exception) {
Timber.e(e)
atomLog { e }
Result.failure()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.hilt.work.HiltWorker
import androidx.work.CoroutineWorker
import androidx.work.OneTimeWorkRequestBuilder
import androidx.work.WorkerParameters
import com.costular.atomtasks.core.logging.atomLog
import com.costular.atomtasks.tasks.interactor.GetTasksWithReminderInteractor
import com.costular.atomtasks.tasks.manager.TaskReminderManager
import dagger.assisted.Assisted
Expand All @@ -29,6 +30,7 @@ class SetTasksRemindersWorker @AssistedInject constructor(
}
Result.success()
} catch (e: Exception) {
atomLog { e }
Result.failure()
}

Expand Down
1 change: 1 addition & 0 deletions core/logging/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
14 changes: 14 additions & 0 deletions core/logging/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
plugins {
id("atomtasks.android.library")
id("atomtasks.detekt")
id("kotlin-kapt")
}

android {
namespace = "com.costular.atomtasks.core.logger.firebase"
}

dependencies {
implementation(platform(libs.firebase.bom))
implementation(libs.firebase.crashlytics)
}
Empty file added core/logging/consumer-rules.pro
Empty file.
21 changes: 21 additions & 0 deletions core/logging/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
4 changes: 4 additions & 0 deletions core/logging/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>
Loading