aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarvin Borner2019-04-07 12:44:08 +0200
committerMarvin Borner2019-04-07 12:44:08 +0200
commit51c6451b36e8f3845ba278d42e7c4a9941556986 (patch)
tree04322889be28112838decb6030f0b16504fa86a0
parentb46ac266bb8625c09c07f7df43cb3da9a0bfe1ac (diff)
Added better logging
-rw-r--r--src/main/kotlin/App.kt6
-rw-r--r--src/main/kotlin/DatabaseController.kt4
2 files changed, 8 insertions, 2 deletions
diff --git a/src/main/kotlin/App.kt b/src/main/kotlin/App.kt
index 0c586e0..f080357 100644
--- a/src/main/kotlin/App.kt
+++ b/src/main/kotlin/App.kt
@@ -3,6 +3,7 @@ package space.anity
import com.fizzed.rocker.*
import com.fizzed.rocker.runtime.*
import io.javalin.*
+import io.javalin.Handler
import io.javalin.apibuilder.ApiBuilder.*
import io.javalin.core.util.*
import io.javalin.rendering.*
@@ -11,9 +12,11 @@ import io.javalin.security.*
import io.javalin.security.SecurityUtil.roles
import java.io.*
import java.nio.file.*
+import java.util.logging.*
const val fileHome = "files"
val databaseController = DatabaseController()
+val LOG = Logger.getLogger("App.kt")
fun main() {
val app = Javalin.create()
@@ -81,7 +84,8 @@ fun crawlFiles(ctx: Context) {
"content", Files.readAllLines(
Paths.get("$fileHome/${ctx.splats()[0]}"),
Charsets.UTF_8
- ).toString()
+ ).toString(),
+ "filename", File("$fileHome/${ctx.splats()[0]}").name
)
)
} catch (_: java.nio.file.NoSuchFileException) {
diff --git a/src/main/kotlin/DatabaseController.kt b/src/main/kotlin/DatabaseController.kt
index 64acc6c..32e33ef 100644
--- a/src/main/kotlin/DatabaseController.kt
+++ b/src/main/kotlin/DatabaseController.kt
@@ -3,9 +3,11 @@ package space.anity
import org.jetbrains.exposed.sql.*
import org.jetbrains.exposed.sql.transactions.*
import java.sql.*
+import java.util.logging.*
class DatabaseController(dbFileLocation: String = "main.db") {
val db: Database
+ val LOG = Logger.getLogger(this.javaClass.name)
/**
* Database table for the file location indexing
@@ -53,7 +55,7 @@ class DatabaseController(dbFileLocation: String = "main.db") {
it[role] = roleString
}
} catch (_: org.jetbrains.exposed.exceptions.ExposedSQLException) {
- println("User already exists")
+ LOG.warning("User already exists!")
}
}