Skip to content

Commit

Permalink
fix(logging) encode try-list as json and no longer use new-line (#55)
Browse files Browse the repository at this point in the history
* fix(logging) encode try-list as json and no longer use new-line

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

fixes #52
  • Loading branch information
Tieske committed Aug 27, 2018
1 parent 3011fdd commit 83ad938
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Versioning is strictly based on [Semantic Versioning](https://semver.org/)

- Added: a new option `validTtl` that, if set, will forcefully override the
`ttl` value of any valid answer received. [Issue 48](https://github.com/Kong/lua-resty-dns-client/issues/48).
- Fix: remove multiline log entries, now encoded as single-line json. [Issue 52](https://github.com/Kong/lua-resty-dns-client/issues/52).

### 2.1.0 (21-May-2018) Fixes

Expand Down
7 changes: 4 additions & 3 deletions src/resty/dns/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -311,20 +311,21 @@ local try_list_mt = {
__tostring = function(self)
local l, i = {}, 0
for _, entry in ipairs(self) do
l[i] = '","'
l[i+1] = entry.qname
l[i+2] = ":"
l[i+3] = entry.qtype or "(na)"
local m = tostring(entry.msg)
local m = tostring(entry.msg):gsub('"',"'")
if m == "" then
i = i + 4
else
l[i+4] = " - "
l[i+5] = m
i = i + 6
end
l[i]="\n"
end
return table_concat(l)
-- concatenate result and encode as json array
return '["' .. table_concat(l) .. '"]'
end
}

Expand Down

0 comments on commit 83ad938

Please sign in to comment.