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

REM-877 - Move logging to the separate module #244

Merged
merged 1 commit into from
Dec 16, 2024
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
11 changes: 7 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ configurations.testImplementation {
}

dependencies {
implementation project(':voice-engine-ktx')
implementation project(':logging-api')
implementation project(':logging')

implementation('com.google.apis:google-api-services-calendar:v3-rev20230406-2.0.0') {
exclude group: 'com.google.guava', module: 'listenablefuture'
}
Expand All @@ -178,7 +182,6 @@ dependencies {
implementation('com.google.apis:google-api-services-drive:v3-rev20230423-2.0.0') {
exclude group: 'org.apache.httpcomponents'
}
implementation project(':voice-engine-ktx')

implementation 'io.insert-koin:koin-android:3.5.6'
implementation 'io.insert-koin:koin-android-ext:3.0.2'
Expand Down Expand Up @@ -221,9 +224,9 @@ dependencies {
implementation 'androidx.navigation:navigation-fragment-ktx:2.8.5'
implementation 'androidx.navigation:navigation-ui-ktx:2.8.5'

implementation platform('com.google.firebase:firebase-bom:33.7.0')
implementation libs.firebase.bom

implementation 'com.google.firebase:firebase-crashlytics'
implementation libs.firebase.crashlytics
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation 'com.google.firebase:firebase-auth-ktx'
implementation 'com.google.firebase:firebase-config'
Expand All @@ -249,7 +252,7 @@ dependencies {
implementation 'com.github.naz013:android-calendar-ext:1.0.4'
implementation 'com.airbnb.android:lottie:6.6.1'
implementation 'com.github.chrisbanes:PhotoView:2.3.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib:2.1.0"
implementation 'org.threeten:threetenbp:1.7.0'
implementation 'com.maxkeppeler.sheets:core:2.3.1'
implementation 'com.maxkeppeler.sheets:lottie:2.3.1'
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/com/elementary/tasks/ReminderApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import androidx.multidex.MultiDex
import androidx.multidex.MultiDexApplication
import com.elementary.tasks.birthdays.birthdaysModule
import com.elementary.tasks.calendar.calendarModule
import com.elementary.tasks.core.analytics.Traces
import com.elementary.tasks.core.appwidgets.widgetModule
import com.elementary.tasks.core.data.adapter.adapterModule
import com.elementary.tasks.core.data.repository.repositoryModule
Expand All @@ -31,6 +30,7 @@ import com.elementary.tasks.home.homeModule
import com.elementary.tasks.notes.noteModule
import com.elementary.tasks.reminder.reminderModule
import com.elementary.tasks.voice.voiceModule
import com.github.naz013.logging.initLogging
import org.koin.android.ext.android.get
import org.koin.android.ext.koin.androidContext
import org.koin.androidx.workmanager.koin.workManagerFactory
Expand All @@ -39,7 +39,6 @@ import org.koin.core.context.startKoin
import org.koin.core.logger.Level
import org.koin.core.logger.Logger
import org.koin.core.logger.MESSAGE
import timber.log.Timber

@Suppress("unused")
class ReminderApp : MultiDexApplication(), KoinComponent {
Expand All @@ -51,8 +50,9 @@ class ReminderApp : MultiDexApplication(), KoinComponent {

override fun onCreate() {
super.onCreate()
if (BuildConfig.DEBUG) Timber.plant(Timber.DebugTree())
Traces.setUpKeys(this)
initLogging(
isDebug = BuildConfig.DEBUG
)
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)
val logger = object : Logger(level = Level.DEBUG) {
override fun display(level: Level, msg: MESSAGE) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import com.elementary.tasks.birthdays.work.SingleBackupWorker
import com.elementary.tasks.core.analytics.AnalyticsEventSender
import com.elementary.tasks.core.analytics.Feature
import com.elementary.tasks.core.analytics.FeatureUsedEvent
import com.elementary.tasks.core.analytics.Traces
import com.elementary.tasks.core.appwidgets.UpdatesHelper
import com.elementary.tasks.core.arch.BaseProgressViewModel
import com.elementary.tasks.core.data.Commands
Expand All @@ -25,9 +24,9 @@ import com.elementary.tasks.core.utils.io.UriReader
import com.elementary.tasks.core.utils.mutableLiveDataOf
import com.elementary.tasks.core.utils.toLiveData
import com.elementary.tasks.core.utils.work.WorkerLauncher
import com.github.naz013.logging.Logger
import kotlinx.coroutines.launch
import org.threeten.bp.LocalDate
import timber.log.Timber
import java.util.UUID

class AddBirthdayViewModel(
Expand Down Expand Up @@ -65,14 +64,14 @@ class AddBirthdayViewModel(
fun load() {
viewModelScope.launch(dispatcherProvider.default()) {
val birthday = birthdaysDao.getById(id) ?: return@launch
Traces.logEvent("Birthday loaded from DB")
Logger.logEvent("Birthday loaded from DB")
onBirthdayLoaded(birthday)
}
}

fun onIntent() {
intentDataHolder.get(Constants.INTENT_ITEM, Birthday::class.java)?.run {
Traces.logEvent("Birthday loaded from intent")
Logger.logEvent("Birthday loaded from intent")
onBirthdayLoaded(this)
isFromFile = true
findSame(uuId)
Expand All @@ -83,7 +82,7 @@ class AddBirthdayViewModel(
viewModelScope.launch(dispatcherProvider.default()) {
runCatching {
uriReader.readBirthdayObject(uri)?.also {
Traces.logEvent("Birthday loaded from file")
Logger.logEvent("Birthday loaded from file")
onBirthdayLoaded(it)
isFromFile = true
findSame(it.uuId)
Expand All @@ -97,7 +96,7 @@ class AddBirthdayViewModel(
}

fun onDateChanged(localDate: LocalDate) {
Timber.d("onDateChanged: $localDate")
Logger.d("onDateChanged: $localDate")
selectedDate = localDate
_formattedDate.postValue(uiBirthdayDateFormatter.getDateFormatted(localDate))
}
Expand Down Expand Up @@ -133,7 +132,7 @@ class AddBirthdayViewModel(
updatedAt = dateTimeManager.getNowGmtDateTime(),
ignoreYear = ignoreYear
)
Traces.logEvent("Birthday saved")
Logger.logEvent("Birthday saved")
analyticsEventSender.send(FeatureUsedEvent(Feature.CREATE_BIRTHDAY))
saveBirthday(birthday)
}
Expand All @@ -147,7 +146,7 @@ class AddBirthdayViewModel(
updatesHelper.updateTasksWidget()
updatesHelper.updateBirthdaysWidget()
workerLauncher.startWork(BirthdayDeleteBackupWorker::class.java, Constants.INTENT_ID, id)
Traces.logEvent("Birthday deleted")
Logger.logEvent("Birthday deleted")
postInProgress(false)
postCommand(Commands.DELETED)
}
Expand Down
59 changes: 0 additions & 59 deletions app/src/main/java/com/elementary/tasks/core/analytics/Traces.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.elementary.tasks.core.appwidgets.singlenote

import android.content.Context
import com.elementary.tasks.core.analytics.Traces
import com.elementary.tasks.core.appwidgets.WidgetPrefsProvider
import com.elementary.tasks.core.utils.ThemeProvider
import com.elementary.tasks.core.views.drawable.NoteDrawableParams
import com.github.naz013.logging.Logger

class SingleNoteWidgetPrefsProvider(
context: Context,
Expand Down Expand Up @@ -57,7 +57,7 @@ class SingleNoteWidgetPrefsProvider(

fun getTextColorPosition(): Int {
return getInt(WIDGET_TEXT_COLOR_POSITION, def = ThemeProvider.Color.BLACK).also {
Traces.d("getTextColorPosition: $it")
Logger.d("getTextColorPosition: $it")
}
}

Expand All @@ -75,7 +75,7 @@ class SingleNoteWidgetPrefsProvider(

fun getOverlayColorPosition(): Int {
return getInt(WIDGET_OVERLAY_COLOR_POSITION, def = ThemeProvider.Color.WHITE).also {
Traces.d("getOverlayColorPosition: $it")
Logger.d("getOverlayColorPosition: $it")
}
}

Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/com/elementary/tasks/core/cloud/DataFlow.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.elementary.tasks.core.cloud

import com.elementary.tasks.core.analytics.Traces
import com.elementary.tasks.core.cloud.completables.Completable
import com.elementary.tasks.core.cloud.converters.Convertible
import com.elementary.tasks.core.cloud.converters.IndexTypes
import com.elementary.tasks.core.cloud.repositories.Repository
import com.elementary.tasks.core.cloud.storages.Storage
import com.elementary.tasks.core.utils.datetime.DateTimeManager
import com.github.naz013.logging.Logger
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject

Expand All @@ -28,7 +28,7 @@ class DataFlow<T>(
val stream = convertible.toOutputStream(item) ?: return
val metadata = convertible.metadata(item)
storage.backup(stream, metadata)
Traces.log("Backed up file with ext = ${metadata.fileExt} and id = ${metadata.id}")
Logger.i("Backed up file with ext = ${metadata.fileExt} and id = ${metadata.id}")
}

suspend fun restore(id: String, type: IndexTypes) {
Expand All @@ -47,7 +47,7 @@ class DataFlow<T>(
true
}
if (needUpdate) {
Traces.log("Saved remote file with ext = ${metadata.fileExt} and id = $id")
Logger.i("Saved remote file with ext = ${metadata.fileExt} and id = $id")
repository.insert(item)
completable?.action(item)
}
Expand All @@ -58,7 +58,7 @@ class DataFlow<T>(
if (id.isEmpty() || fileName.isEmpty()) {
return
}
Traces.log("Delete file with type = $type and id = $id")
Logger.i("Delete file with type = $type and id = $id")
runCatching {
val t = repository.get(id)
if (t != null) {
Expand Down
Loading
Loading