Skip to content

Commit

Permalink
switched to moko parcelize + fixed possible crash because `FileSystem…
Browse files Browse the repository at this point in the history
….SYSTEM.list(folder)` does not work if the folder does not exist
  • Loading branch information
Michael Flisar authored and Michael Flisar committed Nov 18, 2024
1 parent 5ac3f91 commit a007eb8
Show file tree
Hide file tree
Showing 17 changed files with 40 additions and 47 deletions.
2 changes: 1 addition & 1 deletion documentation/_data/other-projects.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ libraries:
description: This is a very small library that allows you to <b>send feedback</b> from an app <b>without internet permission</b> via email, either directly or via an unintrusive notification.
- name: Toolbox
link: https://github.com/MFlisar/Toolbox
maven: io.github.mflisar.toolbox:core
maven: io.github.mflisar.toolbox/core
description: My personal toolbox library
Libraries:
- name: KotBilling
Expand Down
8 changes: 7 additions & 1 deletion gradle/deps.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ slf4j = "2.0.7"
logback = "3.0.0"
fastscroller = "1.0.0"
material = "1.12.0"

# mflisar
feedback = "2.1.0"
toolbox = "2.2.0"
moko-parcelize = "0.9.0"

[libraries]

Expand All @@ -17,7 +20,10 @@ slf4j = { module = "org.slf4j:slf4j-api", version.ref = "slf
logback = { module = "com.github.tony19:logback-android", version.ref = "logback" }
fastscroller = { module = "com.quiph.ui:recyclerviewfastscroller", version.ref = "fastscroller" }
material = { module = "com.google.android.material:material", version.ref = "material" }
moko-parcelize = { module = "dev.icerock.moko:parcelize", version.ref = "moko-parcelize" }

# mflisar
feedback = { module = "io.github.mflisar.feedbackmanager:library", version.ref = "feedback" }
toolbox-core = { module = "io.github.mflisar.toolbox:core", version.ref = "toolbox" }
toolbox-ui = { module = "io.github.mflisar.toolbox:ui", version.ref = "toolbox" }
toolbox-app = { module = "io.github.mflisar.toolbox:android-demo-app", version.ref = "toolbox" }
toolbox-app = { module = "io.github.mflisar.toolbox:android-demo-app", version.ref = "toolbox" }
4 changes: 0 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ compose = { id = "org.jetbrains.compose",

[libraries]

#kotlin = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" }
#kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
#kotlin-serialization = { module = "org.jetbrains.kotlin:kotlin-serialization", version.ref = "kotlin" }

compose-runtime = { module = "org.jetbrains.compose.runtime:runtime", version.ref = "compose" }
compose-material-icons-core = { module = "org.jetbrains.compose.material:material-icons-core", version.ref = "compose" }
compose-material-icons-extended = { module = "org.jetbrains.compose.material:material-icons-extended", version.ref = "compose" }
Expand Down
2 changes: 2 additions & 0 deletions library/core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ kotlin {
// I/O
implementation(deps.okio)

api(deps.moko.parcelize)

}
}
}
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.michaelflisar.lumberjack.core.interfaces

import com.michaelflisar.lumberjack.core.CommonParcelable
import com.michaelflisar.lumberjack.core.classes.Level
import dev.icerock.moko.parcelize.Parcelable

interface IFileConverter : CommonParcelable {
interface IFileConverter : Parcelable {

fun parseFile(lines: List<String>) : List<Entry>
fun formatLog(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.michaelflisar.lumberjack.core.interfaces

import com.michaelflisar.lumberjack.core.CommonParcelable
import dev.icerock.moko.parcelize.Parcelable
import okio.Path

interface IFileLoggingSetup : CommonParcelable {
interface IFileLoggingSetup : Parcelable {

val fileConverter: IFileConverter

Expand Down

This file was deleted.

This file was deleted.

2 changes: 2 additions & 0 deletions library/extensions/composeviewer/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ kotlin {
// Dependencies
implementation(deps.okio)

implementation(deps.moko.parcelize)

}

androidMain.dependencies {
Expand Down
3 changes: 1 addition & 2 deletions library/extensions/core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ kotlin {
commonMain.dependencies {

// Kotlin
implementation(libs.kotlin)
implementation(libs.kotlinx.io.core)
implementation(kotlinx.io.core)

}
}
Expand Down
2 changes: 2 additions & 0 deletions library/loggers/lumberjack/file/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ kotlin {
implementation(project(":Lumberjack:Core"))
implementation(project(":Lumberjack:Implementations:Lumberjack"))

implementation(deps.moko.parcelize)

}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.michaelflisar.lumberjack.loggers.file

import com.michaelflisar.lumberjack.core.CommonIgnoredOnParcel
import com.michaelflisar.lumberjack.implementation.LumberjackLogger
import dev.icerock.moko.parcelize.IgnoredOnParcel
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
Expand All @@ -16,13 +16,13 @@ abstract class BaseFileLoggerSetup : FileLoggerSetup() {
abstract val fileBaseName: String
abstract val fileExtension: String

@CommonIgnoredOnParcel
@IgnoredOnParcel
override val fileConverter = FileConverter

@CommonIgnoredOnParcel
@IgnoredOnParcel
private var lastFileKey: String = ""

@CommonIgnoredOnParcel
@IgnoredOnParcel
private var lastFileKeyChanged: Boolean = false

override fun filePath(data: FileLogger.Event.Data): String {
Expand Down Expand Up @@ -61,9 +61,11 @@ abstract class BaseFileLoggerSetup : FileLoggerSetup() {
}

override fun getAllExistingLogFilePaths(): List<Path> {
return FileSystem.SYSTEM.list(folder.toPath()).filter {
it.name.startsWith(fileBaseName) && it.name.endsWith(".$fileExtension")
}.sortedByDescending { it.name }
return if (FileSystem.SYSTEM.exists(folder.toPath())) {
FileSystem.SYSTEM.list(folder.toPath()).filter {
it.name.startsWith(fileBaseName) && it.name.endsWith(".$fileExtension")
}.sortedByDescending { it.name }
} else emptyList()
}

override fun getLatestLogFilePath(): Path? {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package com.michaelflisar.lumberjack.loggers.file

import com.michaelflisar.lumberjack.core.CommonIgnoredOnParcel
import com.michaelflisar.lumberjack.core.CommonParcelize
import com.michaelflisar.lumberjack.core.classes.Level
import com.michaelflisar.lumberjack.core.interfaces.IFileConverter
import dev.icerock.moko.parcelize.IgnoredOnParcel
import dev.icerock.moko.parcelize.Parcelize
import kotlinx.datetime.LocalDateTime
import kotlinx.datetime.format.char

@CommonParcelize
@Parcelize
object FileConverter : IFileConverter {

// "yyyy-MM-dd HH:mm:ss.SSS"
@CommonIgnoredOnParcel
@IgnoredOnParcel
private val timeFormatter = LocalDateTime.Format {
year()
char('-')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.michaelflisar.lumberjack.loggers.file

import com.michaelflisar.lumberjack.core.CommonIgnoredOnParcel
import com.michaelflisar.lumberjack.core.CommonParcelize
import com.michaelflisar.lumberjack.core.interfaces.IFileLoggingSetup
import dev.icerock.moko.parcelize.IgnoredOnParcel
import dev.icerock.moko.parcelize.Parcelize
import kotlinx.coroutines.CoroutineScope
import kotlinx.datetime.LocalDateTime
import kotlinx.datetime.format
Expand All @@ -21,7 +21,7 @@ sealed class FileLoggerSetup : IFileLoggingSetup {
abstract fun filePath(data: FileLogger.Event.Data): String
abstract fun onLogged(scope: CoroutineScope)

@CommonParcelize
@Parcelize
class Daily internal constructor(
override val folder: String,
override val fileBaseName: String,
Expand All @@ -32,7 +32,7 @@ sealed class FileLoggerSetup : IFileLoggingSetup {
companion object

// "yyyy_MM_dd"
@CommonIgnoredOnParcel
@IgnoredOnParcel
private val timeFormatter = LocalDateTime.Format {
year()
char('_')
Expand All @@ -52,7 +52,7 @@ sealed class FileLoggerSetup : IFileLoggingSetup {
}
}

@CommonParcelize
@Parcelize
class FileSize internal constructor(
override val folder: String,
override val fileBaseName: String,
Expand All @@ -63,7 +63,7 @@ sealed class FileLoggerSetup : IFileLoggingSetup {

companion object

@CommonIgnoredOnParcel
@IgnoredOnParcel
private var fileIndex: Int? = null

override fun getFileKey(data: FileLogger.Event.Data, lastPath: Path): String {
Expand All @@ -88,7 +88,7 @@ sealed class FileLoggerSetup : IFileLoggingSetup {
}
}

@CommonParcelize
@Parcelize
class SingleFile internal constructor(
override val folder: String,
private val fileName: String,
Expand All @@ -97,7 +97,7 @@ sealed class FileLoggerSetup : IFileLoggingSetup {

companion object

@CommonIgnoredOnParcel
@IgnoredOnParcel
override val fileBaseName: String = fileName

override fun getFileKey(data: FileLogger.Event.Data, lastPath: Path): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.michaelflisar.lumberjack.loggers.timber.file

import android.content.Context
import android.os.Parcelable
import com.michaelflisar.lumberjack.core.CommonParcelize
import com.michaelflisar.lumberjack.core.interfaces.IFileConverter
import com.michaelflisar.lumberjack.core.interfaces.IFileLoggingSetup
import kotlinx.coroutines.Dispatchers
Expand Down

0 comments on commit a007eb8

Please sign in to comment.