Skip to content

Commit

Permalink
Improve luatest.log function if a nil value is passed
Browse files Browse the repository at this point in the history
Use `select()` to avoid `bad argument to '?' (no value)` error
in following example:

    luatest.log('%s and %s', cdata<void *>: NULL, nil)

Closes #360
  • Loading branch information
Oleg Chaplashkin authored and ylobankov committed Mar 22, 2024
1 parent e3ea6fc commit 15dbf75
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Add logging to unified file (gh-324).
- Add memory leak detection during server process execution (gh-349).
- Improve `luatest.log` function if a `nil` value is passed (gh-360).

## 1.0.1

Expand Down
7 changes: 4 additions & 3 deletions luatest/log.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ local function _log(level, msg, ...)
if not utils.version_current_ge_than(2, 5, 1) then
return
end
local args = {...}
for k, v in pairs(args) do
args[k] = pp.tostringlog(v)
local args = {}
for i = 1, select('#', ...) do
local v = select(i, ...)
table.insert(args, pp.tostringlog(v))
end
return tarantool_log[level](msg, unpack(args))
end
Expand Down

0 comments on commit 15dbf75

Please sign in to comment.