Tarantool development patches archive
 help / color / mirror / Atom feed
* [Tarantool-patches] [PATCH] say: fix syslog format
@ 2020-03-24  8:52 Olga Arkhangelskaia
  2020-04-14 12:52 ` Igor Munkin
  2020-04-21 16:23 ` Alexander Turenko
  0 siblings, 2 replies; 7+ messages in thread
From: Olga Arkhangelskaia @ 2020-03-24  8:52 UTC (permalink / raw)
  To: tarantool-patches

While refactoring of say module in commit 2.0.4-837-g5db765a76
format of syslog was broken.

Closes #4785
---
 src/lib/core/say.c                   |  6 +++++-
 test/box-tap/gh-4785-syslog.result   |  1 +
 test/box-tap/gh-4785-syslog.test.lua | 22 ++++++++++++++++++++++
 3 files changed, 28 insertions(+), 1 deletion(-)
 create mode 100644 test/box-tap/gh-4785-syslog.result
 create mode 100755 test/box-tap/gh-4785-syslog.test.lua

diff --git a/src/lib/core/say.c b/src/lib/core/say.c
index dd05285a6..d03e687b5 100644
--- a/src/lib/core/say.c
+++ b/src/lib/core/say.c
@@ -199,7 +199,11 @@ void
 say_set_log_format(enum say_format format)
 {
 	log_format_func_t format_func;
-
+	bool allowed_to_change = log_default->type == SAY_LOGGER_STDERR ||
+			         log_default->type == SAY_LOGGER_PIPE ||
+				 log_default->type == SAY_LOGGER_FILE;
+	if (!allowed_to_change)
+		return;
 	switch (format) {
 	case SF_JSON:
 		assert(log_default->type != SAY_LOGGER_SYSLOG);
diff --git a/test/box-tap/gh-4785-syslog.result b/test/box-tap/gh-4785-syslog.result
new file mode 100644
index 000000000..bf3df9e6e
--- /dev/null
+++ b/test/box-tap/gh-4785-syslog.result
@@ -0,0 +1 @@
+<>TIMESTAMP tarantool[PID]: main//gh.test.lua C> Tarantool 
diff --git a/test/box-tap/gh-4785-syslog.test.lua b/test/box-tap/gh-4785-syslog.test.lua
new file mode 100755
index 000000000..586a2eb1a
--- /dev/null
+++ b/test/box-tap/gh-4785-syslog.test.lua
@@ -0,0 +1,22 @@
+#!/usr/bin/env tarantool
+test_run = require('test_run').new()
+
+local socket = require('socket')
+local log = require('log')
+local fio = require('fio')
+
+path = fio.pathjoin(fio.cwd(), 'log_unix_socket_test.sock')
+unix_socket = socket('AF_UNIX', 'SOCK_DGRAM', 0)
+unix_socket:bind('unix/', path)
+
+opt = string.format("syslog:server=unix:%s,identity=tarantool", path)
+local buf = ''
+box.cfg{log = opt}
+buf = buf .. unix_socket:recv(100)
+str = string.format(buf)
+-- Check syslog format: TIMESTAMP IDENTATION[PID]
+--<>TIMESTAMP tarantool[PID]: main//gh.test.lua C> Tarantool
+print(((((str:gsub("%d", "")):gsub("%p%p--%w+", "")):gsub("%w+  ::", "TIMESTAMP")):gsub("]", "PID]")))
+unix_socket:close()
+os.remove(path)
+os.exit(0)
-- 
2.20.1 (Apple Git-117)

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-04-21 16:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-24  8:52 [Tarantool-patches] [PATCH] say: fix syslog format Olga Arkhangelskaia
2020-04-14 12:52 ` Igor Munkin
2020-04-15 13:25   ` Olga Arkhangelskaia
2020-04-16 21:15     ` Igor Munkin
2020-04-17  9:50       ` Olga Arkhangelskaia
2020-04-17 11:56         ` Igor Munkin
2020-04-21 16:23 ` Alexander Turenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox