[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-libeufin] 22/25: Complete initial setup (#5888).
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-libeufin] 22/25: Complete initial setup (#5888). |
Date: |
Fri, 20 Sep 2019 19:33:00 +0200 |
This is an automated email from the git hooks/post-receive script.
marcello pushed a commit to branch master
in repository libeufin.
commit 08b9a9d9103f6107f8c53cc4c91abfdae5015056
Author: Marcello Stanisci <address@hidden>
AuthorDate: Thu Sep 19 02:05:53 2019 +0200
Complete initial setup (#5888).
---
build.gradle | 2 +-
src/main/java/tech/libeufin/GetLogger.java | 21 +++++++++++++++++++++
src/main/kotlin/Main.kt | 18 ++++++++----------
3 files changed, 30 insertions(+), 11 deletions(-)
diff --git a/build.gradle b/build.gradle
index 91d90f4..3338ff3 100644
--- a/build.gradle
+++ b/build.gradle
@@ -15,7 +15,7 @@ repositories {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
compile "io.ktor:ktor-server-netty:1.2.4"
- compile "org.slf4j:slf4j-simple:1.7.28"
+ compile "ch.qos.logback:logback-classic:1.2.3"
testCompile group: 'junit', name: 'junit', version: '4.12'
}
diff --git a/src/main/java/tech/libeufin/GetLogger.java
b/src/main/java/tech/libeufin/GetLogger.java
new file mode 100644
index 0000000..68f0001
--- /dev/null
+++ b/src/main/java/tech/libeufin/GetLogger.java
@@ -0,0 +1,21 @@
+package tech.libeufin;
+
+import ch.qos.logback.classic.Level;
+import org.slf4j.LoggerFactory;
+import ch.qos.logback.core.FileAppender;
+import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.classic.Logger;
+import ch.qos.logback.classic.LoggerContext;
+
+public class GetLogger {
+ public static Logger getLogger() {
+ FileAppender fa = new FileAppender<ILoggingEvent>();
+ LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
+ fa.setContext(lc);
+ fa.setFile("server.log");
+ Logger logger = (Logger) LoggerFactory.getLogger("libeufin-sandbox");
+ logger.addAppender(fa);
+ logger.setLevel(Level.DEBUG);
+ return logger;
+ }
+}
diff --git a/src/main/kotlin/Main.kt b/src/main/kotlin/Main.kt
index 456438c..d614e35 100644
--- a/src/main/kotlin/Main.kt
+++ b/src/main/kotlin/Main.kt
@@ -21,33 +21,31 @@ package tech.libeufin
import io.ktor.application.*
import io.ktor.http.*
-import io.ktor.http.content.TextContent
import io.ktor.request.receiveText
import io.ktor.response.*
import io.ktor.routing.*
import io.ktor.server.engine.*
import io.ktor.server.netty.*
-import tech.libeufin.XMLManagement;
-import java.io.ByteArrayInputStream
-import java.io.InputStream
-import org.w3c.dom.Document;
import tech.libeufin.messages.HEVResponse
-import kotlin.reflect.jvm.internal.impl.load.kotlin.JvmType
fun main(args: Array<String>) {
var xmlProcess = XMLManagement();
+ var logger = GetLogger.getLogger()
+
val server = embeddedServer(Netty, port = 5000) {
routing {
get("/") {
+ logger.debug("GET: not implemented")
call.respondText("Hello LibEuFin!", ContentType.Text.Plain)
}
post("/") {
val body: String = call.receiveText()
- println("Body: $body")
+ logger.debug("Body: $body")
+
val isValid = xmlProcess.validate(body)
if (!isValid) {
- System.out.println("Invalid request received")
+ logger.error("Invalid request received")
call.respondText(contentType = ContentType.Application.Xml,
status = HttpStatusCode.BadRequest) {"Bad
request"};
return@post
@@ -57,7 +55,7 @@ fun main(args: Array<String>) {
if (null == bodyDocument)
{
/* Should never happen. */
- System.out.println("A valid document failed to parse into
DOM!")
+ logger.error("A valid document failed to parse into DOM!")
call.respondText(contentType = ContentType.Application.Xml,
status = HttpStatusCode.InternalServerError)
{"Internal server error"};
return@post
@@ -75,7 +73,7 @@ fun main(args: Array<String>) {
}
/* Log to console and return "unknown type" */
- System.out.println("Unknown message, just logging it!")
+ // logger.info("Unknown message, just logging it!")
call.respondText(contentType = ContentType.Application.Xml,
status = HttpStatusCode.NotFound) {"Not found"};
return@post
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [GNUnet-SVN] [taler-libeufin] 15/25: Abstracting string conversion to "stream"., (continued)
- [GNUnet-SVN] [taler-libeufin] 15/25: Abstracting string conversion to "stream"., gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 16/25: Introducing the converters:, gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 20/25: Server responds with ebicsHEVResponse., gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 18/25: method to get (XML) strings from JAXB objects., gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 23/25: Translating getLogger() into Kotlin., gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 19/25: Importing JAXB scaffolding to reflect ebics "hev" types., gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 21/25: Fix resource loading from JAR., gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 25/25: Finish translating Java into Kotlin., gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 17/25: Check if the message can be handled by the server., gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 24/25: Move XMLManagement.java to Kotlin., gnunet, 2019/09/20
- [GNUnet-SVN] [taler-libeufin] 22/25: Complete initial setup (#5888).,
gnunet <=