Adds logging.
This commit is contained in:
parent
4dd06e057a
commit
9fbbcd48a8
5 changed files with 6 additions and 4 deletions
|
@ -21,7 +21,6 @@ class FilemureApp(repository: SqliteRepository) {
|
||||||
|
|
||||||
fun register(server: Javalin) {
|
fun register(server: Javalin) {
|
||||||
server.beforeMatched { ctx ->
|
server.beforeMatched { ctx ->
|
||||||
println(ctx.req().pathInfo)
|
|
||||||
val userRole = getUserRole(ctx)
|
val userRole = getUserRole(ctx)
|
||||||
if (ctx.routeRoles().isNotEmpty() && !ctx.routeRoles().contains(userRole)) {
|
if (ctx.routeRoles().isNotEmpty() && !ctx.routeRoles().contains(userRole)) {
|
||||||
ctx.redirectPRG("/login")
|
ctx.redirectPRG("/login")
|
||||||
|
|
|
@ -9,9 +9,12 @@ import org.eclipse.jetty.server.session.DefaultSessionCache
|
||||||
import org.eclipse.jetty.server.session.FileSessionDataStore
|
import org.eclipse.jetty.server.session.FileSessionDataStore
|
||||||
import org.eclipse.jetty.server.session.SessionHandler
|
import org.eclipse.jetty.server.session.SessionHandler
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import java.time.LocalDateTime
|
||||||
|
import java.time.format.DateTimeFormatter
|
||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
|
val dtf = DateTimeFormatter.ISO_DATE_TIME
|
||||||
|
|
||||||
val db = System.getenv("dbpath")
|
val db = System.getenv("dbpath")
|
||||||
?: throw IllegalArgumentException("Please define an env dbpath, e.g. /data/filemure.db")
|
?: throw IllegalArgumentException("Please define an env dbpath, e.g. /data/filemure.db")
|
||||||
|
|
||||||
|
@ -22,11 +25,11 @@ fun main() {
|
||||||
config.staticFiles.add { staticFiles ->
|
config.staticFiles.add { staticFiles ->
|
||||||
staticFiles.hostedPath = "/"
|
staticFiles.hostedPath = "/"
|
||||||
staticFiles.directory = "./public"
|
staticFiles.directory = "./public"
|
||||||
staticFiles.location = Location.EXTERNAL
|
staticFiles.location = Location.CLASSPATH
|
||||||
}
|
}
|
||||||
|
|
||||||
config.requestLogger.http { ctx, ms ->
|
config.requestLogger.http { ctx, ms ->
|
||||||
// log things here
|
println("${dtf.format(LocalDateTime.now())}\t${ctx.method()}\t${ctx.path()}\t$ms")
|
||||||
}
|
}
|
||||||
|
|
||||||
config.useVirtualThreads = true
|
config.useVirtualThreads = true
|
||||||
|
|
Before Width: | Height: | Size: 530 B After Width: | Height: | Size: 530 B |
Loading…
Reference in a new issue