Skip to content

Commit

Permalink
Logging queries and results to info log
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaro committed Jan 27, 2024
1 parent b08b5fc commit 28588b2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 6 additions & 0 deletions vitrivr-engine-server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,10 @@ dependencies {
application {
mainClassName = 'org.vitrivr.engine.server.MainKt'
applicationDefaultJvmArgs = ["-Xms2G", "-Xmx8G"]
}

startScripts {
doLast {
windowsScript.text = windowsScript.text.replaceAll('set CLASSPATH=.*', 'set CLASSPATH=.;%APP_HOME%/lib/*')
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
package org.vitrivr.engine.server.api.rest.handlers

import io.github.oshai.kotlinlogging.KLogger
import io.github.oshai.kotlinlogging.KotlinLogging
import io.javalin.http.Context
import io.javalin.http.bodyAsClass
import io.javalin.openapi.*
import kotlinx.serialization.json.Json
import org.vitrivr.engine.core.model.metamodel.Schema
import org.vitrivr.engine.query.execution.RetrievalRuntime
import org.vitrivr.engine.query.model.api.InformationNeedDescription
import org.vitrivr.engine.query.model.api.result.QueryResult
import org.vitrivr.engine.server.api.rest.model.ErrorStatus
import org.vitrivr.engine.server.api.rest.model.ErrorStatusException

private val logger: KLogger = KotlinLogging.logger {}

/**
*
* @author Ralph Gasser
Expand All @@ -36,6 +41,9 @@ fun executeQuery(ctx: Context, schema: Schema, runtime: RetrievalRuntime) {
} catch (e: Exception) {
throw ErrorStatusException(400, "Invalid request: ${e.message}")
}
logger.info { "received request for ${schema.name}: ${Json.encodeToString(InformationNeedDescription.serializer(), informationNeed)}" }
val results = runtime.query(schema, informationNeed)
ctx.json(QueryResult(results))
val queryResult = QueryResult(results)
logger.info { "returning results for ${schema.name}: ${Json.encodeToString(QueryResult.serializer(), queryResult)}" }
ctx.json(queryResult)
}

0 comments on commit 28588b2

Please sign in to comment.