diff --git a/src/lua/log.lua b/src/lua/log.lua index 94d8ca46c40469b8532045462dec33abaf5c80bf..d5a99076d682c80ed718d953f4e96d1934bd2d2f 100644 --- a/src/lua/log.lua +++ b/src/lua/log.lua @@ -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 diff --git a/test/app-tap/logger.test.lua b/test/app-tap/logger.test.lua index 492d5ea0b49eec4d99898e13bed9a376a2681971..222343908f917ccdea3bbca1dfdc018ed206f971 100755 --- a/test/app-tap/logger.test.lua +++ b/test/app-tap/logger.test.lua @@ -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