feat: logger
This commit is contained in:
parent
7192bbd7fa
commit
9bc92951e4
8 changed files with 92 additions and 2 deletions
|
@ -7,6 +7,7 @@ import androidx.compose.runtime.remember
|
|||
import androidx.compose.ui.window.Window
|
||||
import androidx.compose.ui.window.application
|
||||
import xyz.atnrch.wrench.display.WrenchDisplay
|
||||
import xyz.atnrch.wrench.logger.Logger
|
||||
import xyz.atnrch.wrench.scheduler.Watcher
|
||||
|
||||
@Composable
|
||||
|
@ -23,7 +24,12 @@ fun App() {
|
|||
}
|
||||
|
||||
fun main() = application {
|
||||
Window(onCloseRequest = ::exitApplication, title = "Wrench") {
|
||||
Window(onCloseRequest = {
|
||||
Logger.info("Stopping Wrench...")
|
||||
Logger.info("bye!")
|
||||
::exitApplication.invoke()
|
||||
}, title = "Wrench") {
|
||||
Logger.info("Starting Wrench...")
|
||||
App()
|
||||
}
|
||||
}
|
||||
|
|
7
src/main/kotlin/xyz/atnrch/wrench/WrenchApp.kt
Normal file
7
src/main/kotlin/xyz/atnrch/wrench/WrenchApp.kt
Normal file
|
@ -0,0 +1,7 @@
|
|||
package xyz.atnrch.wrench
|
||||
|
||||
class WrenchApp {
|
||||
companion object {
|
||||
const val PREFIX: String = "(Wrench)"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package xyz.atnrch.wrench.display.file
|
||||
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
|
||||
@Composable
|
||||
fun WrenchFileManagerInput() {
|
||||
Box(
|
||||
contentAlignment = Alignment.CenterStart,
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
) {
|
||||
Column {
|
||||
Text("Test")
|
||||
Text("Test2")
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package xyz.atnrch.wrench.display.file
|
||||
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
|
||||
@Composable
|
||||
fun WrenchFileManagerInput() {
|
||||
Box(
|
||||
contentAlignment = Alignment.CenterStart,
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
) {
|
||||
Column {
|
||||
Text("Test")
|
||||
Text("Test2")
|
||||
}
|
||||
}
|
||||
}
|
33
src/main/kotlin/xyz/atnrch/wrench/logger/Logger.kt
Normal file
33
src/main/kotlin/xyz/atnrch/wrench/logger/Logger.kt
Normal file
|
@ -0,0 +1,33 @@
|
|||
package xyz.atnrch.wrench.logger
|
||||
|
||||
import xyz.atnrch.wrench.WrenchApp
|
||||
|
||||
class Logger {
|
||||
companion object {
|
||||
private fun log(level: Level, log: String) {
|
||||
println("${WrenchApp.PREFIX} - ${level.getName()} - $log")
|
||||
}
|
||||
|
||||
fun debug(log: String) {
|
||||
log(Level.DEBUG, log)
|
||||
}
|
||||
|
||||
fun info(log: String) {
|
||||
log(Level.INFO, log)
|
||||
}
|
||||
|
||||
fun warn(log: String) {
|
||||
log(Level.WARN, log)
|
||||
}
|
||||
}
|
||||
|
||||
enum class Level {
|
||||
INFO,
|
||||
DEBUG,
|
||||
WARN;
|
||||
|
||||
fun getName(): String {
|
||||
return name.lowercase().replaceFirstChar(Char::titlecase)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -18,7 +18,6 @@ class Watcher {
|
|||
WATCHING = true
|
||||
while (WATCHING) {
|
||||
delay(TimeUnit.SECONDS.toMillis(5))
|
||||
println("Hello world!")
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,5 +11,6 @@ class IOManager {
|
|||
|
||||
fun addFile(file: File) {
|
||||
val path = IOPath(file, arrayListOf())
|
||||
println("")
|
||||
}
|
||||
}
|
Reference in a new issue