Skip to content

Commit

Permalink
make http loggers more consistent
Browse files Browse the repository at this point in the history
Previously, ContentsLogger did not implement the Logger interface. There
were also some inconsistencies between the parameter names in the Logger
apply method across its implementations.
  • Loading branch information
Theodus authored and SeanTAllen committed Nov 15, 2017
1 parent 512e017 commit 31b7750
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
8 changes: 6 additions & 2 deletions packages/net/http/common_log.pony
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ class CommonLog is Logger
new val create(out: OutStream) =>
_out = out

fun val apply(ip: String, body_size: USize,
request: Payload val, response: Payload val) =>
fun val apply(
ip: String,
body_size: USize,
request: Payload val,
response: Payload val)
=>

let list = recover Array[String](24) end

Expand Down
17 changes: 9 additions & 8 deletions packages/net/http/contents_log.pony
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class ContentsLog
class ContentsLog is Logger
"""
Logs the contents of HTTP requests and responses.
"""
Expand All @@ -7,7 +7,12 @@ class ContentsLog
new val create(out: OutStream) =>
_out = out

fun val apply(ip: String, request: Payload val, response: Payload val) ? =>
fun val apply(
ip: String,
body_size: USize,
request: Payload val,
response: Payload val)
=>
let list = recover Array[ByteSeq] end

list.push("REQUEST\n")
Expand Down Expand Up @@ -36,9 +41,7 @@ class ContentsLog
list.push("\n")
end

for data in request.body()?.values() do
list.push(data)
end
try list.append(request.body()?) end

list.push("\n")

Expand All @@ -57,9 +60,7 @@ class ContentsLog
list.push("\n")
end

for data in response.body()?.values() do
list.push(data)
end
try list.append(response.body()?) end

list.push("\n\n")
_out.writev(consume list)
2 changes: 1 addition & 1 deletion packages/net/http/discard_log.pony
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ primitive DiscardLog
"""
fun val apply(
ip: String,
transferred: USize,
body_size: USize,
request: Payload val,
response: Payload val)
=>
Expand Down
2 changes: 1 addition & 1 deletion packages/net/http/server_notify.pony
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ interface val Logger
"""
fun val apply(
ip: String,
transfer: USize,
body_size: USize,
request: Payload val,
response: Payload val)
: Any
Expand Down

0 comments on commit 31b7750

Please sign in to comment.