From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Tue, 5 Mar 2019 17:21:40 +0300 From: Vladimir Davydov Subject: Re: [tarantool-patches] [PATCH] log: add missing assert into log_set_format() Message-ID: <20190305142140.3mguirkwwsk3waho@esperanza> References: <20190302172946.94121-1-roman.habibov@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190302172946.94121-1-roman.habibov@tarantool.org> To: Roman Khabibov Cc: tarantool-patches@freelists.org, v.shpilevoy@tarantool.org List-ID: On Sat, Mar 02, 2019 at 08:29:46PM +0300, Roman Khabibov wrote: > Add missing condition for json format into assert in log_set_format() function. > > Closes #3946 > --- > > Branch: https://github.com/tarantool/tarantool/tree/romanhabibov/gh-3946-log-assert/test > Issue: https://github.com/tarantool/tarantool/issues/3946 > > src/lib/core/say.c | 3 ++- > test/app-tap/logger.test.lua | 6 +++++- > 2 files changed, 7 insertions(+), 2 deletions(-) > > diff --git a/src/lib/core/say.c b/src/lib/core/say.c > index 50ee55692..758b1c234 100644 > --- a/src/lib/core/say.c > +++ b/src/lib/core/say.c > @@ -170,7 +170,8 @@ log_set_level(struct log *log, enum say_level level) > void > log_set_format(struct log *log, log_format_func_t format_func) > { > - assert(format_func == say_format_plain || > + assert(format_func == say_format_json || > + format_func == say_format_plain || > log->type == SAY_LOGGER_STDERR || > log->type == SAY_LOGGER_PIPE || log->type == SAY_LOGGER_FILE); The assertion is meaningless after this change. At least the log->type check. I guess the idea was to check that json format isn't used in conjunction with syslog. Also, there's another similar assertion failure that I think should be fixed in the scope of this patch: box.cfg{log = 'syslog:identity=tarantool'} require('log').log_format('json') tarantool: /home/vlad/src/tarantool/src/lib/core/say.c:195: say_set_log_format: Assertion `log_default->type != SAY_LOGGER_SYSLOG' failed. > > diff --git a/test/app-tap/logger.test.lua b/test/app-tap/logger.test.lua > index 0c11702c8..4e18d53e9 100755 > --- a/test/app-tap/logger.test.lua > +++ b/test/app-tap/logger.test.lua > @@ -1,13 +1,17 @@ > #!/usr/bin/env tarantool > > local test = require('tap').test('log') > -test:plan(24) > +test:plan(25) > > -- > -- Check that Tarantool creates ADMIN session for #! script > -- > local filename = "1.log" > local message = "Hello, World!" > + > +jlog = require('log') > +test:ok(jlog.log_format("json") == nil, "no assertions") > + Squeezing a test case like this, without a proper comment, looks bad - it seems that the comment above is related to it although it isn't. Also, jlog is a bad name. If you don't want to pollute the namespace, you can get along without it: require('log').log_format('json') > box.cfg{ > log=filename, > memtx_memory=107374182,