From 75c5b6b6e04e397b48e863898f82ec5944e1f266 Mon Sep 17 00:00:00 2001 From: Dominik Picheta Date: Wed, 18 Jul 2018 16:27:11 +0100 Subject: [PATCH] Better logging output. --- jester.nim | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/jester.nim b/jester.nim index 5bf56de..e7f5bbf 100644 --- a/jester.nim +++ b/jester.nim @@ -74,6 +74,9 @@ type const jesterVer = "0.3.1" +proc toStr(headers: Option[RawHeaders]): string = + return $newHttpHeaders(headers.get(@({:}))) + proc createHeaders(headers: RawHeaders): string = result = "" if headers != nil: @@ -112,7 +115,7 @@ proc statusContent(request: Request, status: HttpCode, content: string, try: send(request, status, headers, content) when not defined(release): - logging.debug(" $1 $2" % [$status, $headers]) + logging.debug(" $1 $2" % [$status, toStr(headers)]) except: logging.error("Could not send response: $1" % osErrorMsg(osLastError())) @@ -305,6 +308,9 @@ proc handleFileRequest( # Http200 means that the data was sent so there is nothing else to do. if status == Http200: + result[0] = TCActionRaw + when not defined(release): + logging.debug(" -> $1" % path) return return (TCActionSend, status, none[seq[(string, string)]](), "", true) @@ -348,7 +354,8 @@ proc handleRequestSlow( respData.headers ) else: - logging.debug(" $1" % [$respData.action]) + when not defined(release): + logging.debug(" $1" % [$respData.action]) # Cannot close the client socket. AsyncHttpServer may be keeping it alive.