Skip to content

Commit

Permalink
lua/log: do not allow to set json for boot logger
Browse files Browse the repository at this point in the history
For some reason we've missed that say_set_log_format
doesn't support json format not only for syslog but
for boottime logging as well.

Part-of #689

Reviewed-by: Oleg Babin <olegrok@tarantool.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
  • Loading branch information
cyrillos authored and kyukhin committed Jun 3, 2020
1 parent 94ef2cf commit c85f5db
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/lua/log.lua
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,11 @@ local function log_format(name)
end

if fmt_str2num[name] == ffi.C.SF_JSON then
if ffi.C.log_type() == ffi.C.SAY_LOGGER_SYSLOG then
error("log_format: 'json' can't be used with syslog logger")
if ffi.C.log_type() == ffi.C.SAY_LOGGER_SYSLOG or
ffi.C.log_type() == ffi.C.SAY_LOGGER_BOOT then
local m = "log_format: %s can't be used with " ..
"syslog or boot-time logger"
error(m:format(fmt_num2str[ffi.C.SF_JSON]))
end
ffi.C.say_set_log_format(ffi.C.SF_JSON)
else
Expand Down
5 changes: 3 additions & 2 deletions test/app-tap/logger.test.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#!/usr/bin/env tarantool

local test = require('tap').test('log')
test:plan(24)
test:plan(25)

-- gh-3946: Assertion failure when using log_format() before box.cfg()
local log = require('log')
log.log_format('json')
log.log_format('plain')
_, err = pcall(log.log_format, 'json')
test:ok(err:find("log_format: json can\'t be used") ~= nil)

--
-- Check that Tarantool creates ADMIN session for #! script
Expand Down

0 comments on commit c85f5db

Please sign in to comment.