Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Flisar authored and Michael Flisar committed Nov 19, 2024
1 parent a007eb8 commit 74789a3
Show file tree
Hide file tree
Showing 19 changed files with 103 additions and 88 deletions.
6 changes: 3 additions & 3 deletions demo/android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ dependencies {
implementation(project(":Lumberjack:Extensions:ComposeViewer"))

// a minimal library that provides some useful composables that I use inside demo activities
implementation(deps.toolbox.core)
implementation(deps.toolbox.ui)
implementation(deps.toolbox.app)
implementation(deps.toolbox.android.demo.app) {
exclude(group = "io.github.mflisar.lumberjack")
}
}
8 changes: 4 additions & 4 deletions documentation/_data/project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ library:
# optional
dependencies:
compose:
cmp: 1.7.0
compose: 1.7.1
material3: 1.3.0
experimantal: true
cmp: 1.7.1
compose: 1.7.5
material3: 1.3.1
experimental: true

# -------------
# Module
Expand Down
2 changes: 1 addition & 1 deletion documentation/_include/dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
|:---------------------:|:-------:|:----------------------------------------------:|
| Compose Multiplatform | `{{ project["dependencies"]["compose"]["cmp"] }}` | Uses compose `{{ project["dependencies"]["compose"]["compose"] }}` and material3 `{{ project["dependencies"]["compose"]["material3"] }}` |

{% if project["dependencies"]["compose"]["experimantal"] %}
{% if project["dependencies"]["compose"]["experimental"] %}

!!! warning

Expand Down
6 changes: 2 additions & 4 deletions gradle/deps.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ material = "1.12.0"

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

[libraries]
Expand All @@ -24,6 +24,4 @@ moko-parcelize = { module = "dev.icerock.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-android-demo-app = { module = "io.github.mflisar.toolbox:android-demo-app", version.ref = "toolbox" }
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[versions]

gradle = "8.5.2"
gradle = "8.7.2"
kotlin = "2.0.21"
dokka = "1.9.20"
gradle-maven-publish-plugin = "0.30.0"
compose = "1.7.0"
compose = "1.7.1"

[plugins]

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.michaelflisar.lumberjack.extensions.composeviewer

import android.content.Context
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext
import com.michaelflisar.lumberjack.core.L
import com.michaelflisar.lumberjack.extensions.composeviewer.internal.IFeedbackProvider
import com.michaelflisar.lumberjack.extensions.feedback.sendFeedback
import okio.Path

internal class FeedbackImpl : IFeedbackProvider {

private lateinit var context: Context

override fun supported() = false

@Composable
override fun Init() {
context = LocalContext.current
}

override fun sendFeedback(
receiver: String,
attachments: List<Path>
) {
L.sendFeedback(
context = context,
receiver = receiver,
attachments = attachments.map { it.toFile() }
)
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
package com.michaelflisar.lumberjack.extensions.composeviewer

import android.content.Context
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.ui.platform.LocalContext
import com.michaelflisar.lumberjack.core.L
import com.michaelflisar.lumberjack.core.interfaces.IFileLoggingSetup
import com.michaelflisar.lumberjack.extensions.feedback.sendFeedback
import okio.Path
import com.michaelflisar.lumberjack.extensions.composeviewer.internal.IFeedbackProvider

@Composable
internal actual fun ShowLumberjackDialog(
Expand All @@ -28,25 +23,6 @@ internal actual fun LazyScrollContainer(state: LazyListState, content: LazyListS
}
}

actual class FeedbackImpl actual constructor() {

private lateinit var context: Context

actual fun supported() = false

@Composable
actual fun Init() {
context = LocalContext.current
}

actual fun sendFeedback(
receiver: String,
attachments: List<Path>
) {
L.sendFeedback(
context = context,
receiver = receiver,
attachments = attachments.map { it.toFile() }
)
}
internal actual fun getFeedbackImpl(): IFeedbackProvider {
return FeedbackImpl()
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import androidx.compose.material3.ExposedDropdownMenuDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.MenuAnchorType
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
Expand Down Expand Up @@ -240,7 +241,7 @@ private fun Filter(
}
) {
OutlinedTextField(
modifier = Modifier.menuAnchor(),
modifier = Modifier.menuAnchor(MenuAnchorType.PrimaryNotEditable),
readOnly = true,
value = getLevelName(filter.value),
singleLine = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import com.michaelflisar.lumberjack.extensions.composeviewer.internal.IFeedbackProvider
import okio.Path

@Composable
Expand All @@ -16,12 +17,4 @@ internal expect fun ShowLumberjackDialog(
@Composable
internal expect fun LazyScrollContainer(state: LazyListState, content: LazyListScope.() -> Unit)

expect class FeedbackImpl() {

fun supported(): Boolean

@Composable
fun Init()

fun sendFeedback(receiver: String, attachments: List<Path>)
}
internal expect fun getFeedbackImpl(): IFeedbackProvider
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fun TopAppBarImpl(
var showMenu by remember { mutableStateOf(false) }
var showMenu2 by remember { mutableStateOf(false) }
val feedback by remember {
derivedStateOf { FeedbackImpl() }
derivedStateOf { getFeedbackImpl() }
}
feedback.Init()
androidx.compose.material3.TopAppBar(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.michaelflisar.lumberjack.extensions.composeviewer.internal

import androidx.compose.runtime.Composable
import okio.Path

internal interface IFeedbackProvider {

fun supported(): Boolean

@Composable
fun Init()

fun sendFeedback(receiver: String, attachments: List<Path>)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.michaelflisar.lumberjack.extensions.composeviewer

import androidx.compose.runtime.Composable
import com.michaelflisar.lumberjack.extensions.composeviewer.internal.IFeedbackProvider
import okio.Path

internal class FeedbackImpl : IFeedbackProvider {

override fun supported() = false

@Composable
override fun Init() {
// empty
}

override fun sendFeedback(
receiver: String,
attachments: List<Path>
) {
// empty
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.DialogWindow
import androidx.compose.ui.window.WindowPosition
import androidx.compose.ui.window.rememberDialogState
import okio.Path
import com.michaelflisar.lumberjack.extensions.composeviewer.internal.IFeedbackProvider

@Composable
internal actual fun ShowLumberjackDialog(
Expand Down Expand Up @@ -55,19 +55,7 @@ internal actual fun LazyScrollContainer(state: LazyListState, content: LazyListS
}
}

actual class FeedbackImpl actual constructor() {

actual fun supported() = false

@Composable
actual fun Init() {
// empty
}
internal actual fun getFeedbackImpl(): IFeedbackProvider {
return FeedbackImpl()
}

actual fun sendFeedback(
receiver: String,
attachments: List<Path>
) {
// empty
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package com.michaelflisar.lumberjack.implementation

import com.michaelflisar.lumberjack.core.classes.Level

expect object Log {
fun println(prefix: String, level: Level, tag: String?, log: String)
}
expect fun platformPrintln(prefix: String, level: Level, tag: String?, log: String)


Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.michaelflisar.lumberjack.implementation.classes

import com.michaelflisar.lumberjack.core.classes.Level
import com.michaelflisar.lumberjack.implementation.Log
import com.michaelflisar.lumberjack.implementation.platformPrintln

internal data class StackData(
val stackTrace: List<StackTraceElement>,
Expand Down Expand Up @@ -50,7 +50,7 @@ internal data class StackData(
i = stackTrace.size - 1
val error = "Synthetic stacktrace didn't have enough elements: are you using proguard?"
println(error)
Log.println("", Level.ERROR, "StackData", error)
platformPrintln("", Level.ERROR, "StackData", error)
}
return stackTrace[i]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ package com.michaelflisar.lumberjack.implementation

import com.michaelflisar.lumberjack.core.classes.Level

actual object Log {

actual fun println(prefix: String, level: Level, tag: String?, log: String) {
println("${prefix.let { "$it " }}[${level.shortcut}]${tag?.let { " <$it>" } ?: ""} $log")
}
actual fun platformPrintln(prefix: String, level: Level, tag: String?, log: String) {
println("${prefix.let { "$it " }}[${level.shortcut}]${tag?.let { " <$it>" } ?: ""} $log")
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package com.michaelflisar.lumberjack.implementation
import com.michaelflisar.lumberjack.core.classes.Level
import com.michaelflisar.lumberjack.core.classes.priority

actual object Log {
actual fun println(prefix: String, level: Level, tag: String?, log: String) {
android.util.Log.println(level.priority, tag, log)
}
actual fun platformPrintln(prefix: String, level: Level, tag: String?, log: String) {
android.util.Log.println(level.priority, tag, log)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.michaelflisar.lumberjack.loggers.console

import com.michaelflisar.lumberjack.implementation.Log
import com.michaelflisar.lumberjack.implementation.platformPrintln
import com.michaelflisar.lumberjack.core.classes.Level
import com.michaelflisar.lumberjack.implementation.classes.DefaultLumberjackFilter
import com.michaelflisar.lumberjack.implementation.classes.LumberjackFilter
Expand Down Expand Up @@ -30,7 +30,7 @@ class ConsoleLogger(
link.takeIf { throwable == null },
throwable?.stackTraceToString()?.let { "\n$it" }
).joinToString(" ")
Log.println(prefix, level, tag, log)
platformPrintln(prefix, level, tag, log)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ package com.michaelflisar.lumberjack.loggers.file

import com.michaelflisar.lumberjack.core.L
import com.michaelflisar.lumberjack.core.classes.Level
import com.michaelflisar.lumberjack.implementation.Log
import com.michaelflisar.lumberjack.implementation.classes.DefaultLumberjackFilter
import com.michaelflisar.lumberjack.implementation.classes.LumberjackFilter
import com.michaelflisar.lumberjack.implementation.interfaces.ILumberjackLogger
import com.michaelflisar.lumberjack.implementation.platformPrintln
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.IO
import kotlinx.coroutines.Job
import kotlinx.coroutines.cancelAndJoin
import kotlinx.coroutines.channels.Channel
Expand All @@ -20,7 +19,6 @@ import okio.BufferedSink
import okio.FileSystem
import okio.Path
import okio.Path.Companion.toPath
import okio.SYSTEM
import okio.buffer

class FileLogger(
Expand Down Expand Up @@ -112,7 +110,7 @@ class FileLogger(
closeBufferJob?.cancelAndJoin()
closeBufferJob = createCloseBufferJob()
} catch (e: Exception) {
Log.println(
platformPrintln(
"",
Level.ERROR,
TAG,
Expand Down

0 comments on commit 74789a3

Please sign in to comment.