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

Debug writer #638

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Debug writer #638

wants to merge 8 commits into from

Conversation

Rsedaikin
Copy link
Contributor

DebugWriterTool - simple app for getting basic info about PC/Mac when using CFD.

@Rsedaikin Rsedaikin requested review from igordmn and olonho May 6, 2021 10:11
@@ -0,0 +1,4 @@
Compose Desktop Application
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to change README :)

@@ -0,0 +1,4 @@
Compose Desktop Application

- `./gradlew run` - run application
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I run on Windows:
image

Looking at the code it seems this project is just a template and we will add functionality in the future?


private val fileName = "${System.getProperty("user.home")}/.debug-writer/debug-info.txt"
private var output by mutableStateOf("")
private var isReady by mutableStateOf(true)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we set this to 'false' by default then we will show Loading immediately on the first frame

}

if (result) {
writeDebugInfo()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid launching a coroutine on every recomposition, better to write something like this:

...
     Button("Refresh", Modifier.weight(1f), {
         isReady = false
         GlobalScope.launch { writeDebugInfo() }
     })
...

        if (result) {
            LaunchedEffect(Unit) {
                writeDebugInfo()
            }
        }
...
private suspend fun writeDebugInfo() {
    delay(2000L)
    val result = readDebugOutput(fileName)
    output = if (result.isEmpty()) "Something went wrong and $fileName is empty." else result
    isReady = true
}

Loader(Modifier.weight(1f).fillMaxWidth())
}
Row(modifier = Modifier.fillMaxWidth()) {
Button("Refresh", Modifier.weight(1f), { writeDebugInfo() })
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid multiple parallel writings when user clicks multiple times better to hide/disable button when isReady == true

fun main() {
val result = enableDebugWritingTo(fileName)
if (!result) {
output = "Failed to cteate file: $fileName"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"create".
Overall placement of this code here looks somewhat strange, can we have it somewhere below and have an option to write to file in the way user wants it or copy-paste to clipboard.

@esafak
Copy link
Contributor

esafak commented Aug 9, 2023

Is this still being worked on?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants