fix compile time error when using chronicles sink:json

fixes #73
This commit is contained in:
jangko 2021-06-25 12:46:57 +07:00 committed by Tanguy Cizain
parent 781cb35200
commit 7e668c4c85
No known key found for this signature in database
GPG Key ID: B88D312FB0C84FA5
3 changed files with 7 additions and 4 deletions

View File

@ -25,6 +25,9 @@ requires "bearssl"
requires "https://github.com/status-im/nim-zlib"
task test, "run tests":
# dont't need to run it, only want to test if it is compileable
exec "nim c -c --verbosity:0 --hints:off -d:chronicles_log_level=TRACE -d:chronicles_sinks:json ./tests/testcommon"
exec "nim --hints:off c -r --opt:speed -d:debug --verbosity:0 --hints:off -d:chronicles_log_level=info ./tests/testcommon.nim"
rmFile "./tests/testcommon"

View File

@ -38,13 +38,13 @@ proc validateRequest(
##
if header.meth notin {MethodGet}:
trace "GET method is only allowed", address = stream.tsource.remoteAddress()
trace "GET method is only allowed", address = $stream.tsource.remoteAddress()
await stream.sendError(Http405, version = header.version)
return ReqStatus.Error
var hlen = header.contentLength()
if hlen < 0 or hlen > MaxHttpRequestSize:
trace "Invalid header length", address = stream.tsource.remoteAddress()
trace "Invalid header length", address = $stream.tsource.remoteAddress()
await stream.sendError(Http413, version = header.version)
return ReqStatus.Error

View File

@ -184,7 +184,7 @@ proc handleClose*(
raise newException(WSInvalidUTF8,
"Invalid UTF8 sequence detected in close reason")
trace "Handling close message", code, reason
trace "Handling close message", code = $code, reason
if not isNil(ws.onClose):
try:
(code, reason) = ws.onClose(code, reason)
@ -197,7 +197,7 @@ proc handleClose*(
# don't respond to a terminated connection
if ws.readyState != ReadyState.Closing:
ws.readyState = ReadyState.Closing
trace "Sending close", code, reason
trace "Sending close", code = $code, reason
await ws.send(prepareCloseBody(code, reason), Opcode.Close)
ws.readyState = ReadyState.Closed