Kong / lua-resty-dns-client

Lua DNS client, load balancer, and utility library
http://kong.github.io/lua-resty-dns-client/topics/README.md.html
Apache License 2.0
152 stars 52 forks source link

fix(logging) encode try-list as json and no longer use new-line #55

Closed Tieske closed 6 years ago

Tieske commented 6 years ago

New-line characters in the logging are impossible to parse correctly so should be prevented.

fixes #52

Tieske commented 6 years ago

@hishamhm the whole string is build as a table with a single concat operation. I replace the newline because inserting ", " (the two double quotes are part of it!) would not allow for the safty operation that replaces all double quotes by single quotes. If I forego on that, I'm afraid that a future me might mess up by returning an error that includes a double-quote, and breaks the encoding.

The alternative would be to replace the double quotes on each string inserted into the "concat"-ed table, but that probably is less performant, hence I left it like this.

Tieske commented 6 years ago

@hishamhm updated as per comments, removed spaces and dropped the newline. Please have another look.