[Tarantool-patches] [PATCH v8 01/12] core/say: do not reconfig early set up logger
Cyrill Gorcunov
gorcunov at gmail.com
Wed Jun 3 01:18:06 MSK 2020
We gonna support logger configuration on its own
without requirement to call `box.cfg{}`. Thus lets
say_logger_init() to skip processing if we already
did.
Note it is preparatory for next patches. Currently
the init called once.
Part-of #689
Reviewed-by: Oleg Babin <olegrok at tarantool.org>
Reviewed-by: Leonid Vasiliev <lvasiliev at tarantool.org>
Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
---
src/lib/core/say.c | 13 +++++++++++++
src/lib/core/say.h | 4 ++++
2 files changed, 17 insertions(+)
diff --git a/src/lib/core/say.c b/src/lib/core/say.c
index e22089aac..d8f59fb9b 100644
--- a/src/lib/core/say.c
+++ b/src/lib/core/say.c
@@ -684,10 +684,23 @@ log_create(struct log *log, const char *init_str, int nonblock)
return 0;
}
+bool
+say_logger_initialized(void)
+{
+ return log_default == &log_std;
+}
+
void
say_logger_init(const char *init_str, int level, int nonblock,
const char *format, int background)
{
+ /*
+ * The logger may be early configured
+ * by hands without configuing the whole box.
+ */
+ if (say_logger_initialized())
+ return;
+
if (log_create(&log_std, init_str, nonblock) < 0)
goto fail;
diff --git a/src/lib/core/say.h b/src/lib/core/say.h
index c50d7bbf4..857145465 100644
--- a/src/lib/core/say.h
+++ b/src/lib/core/say.h
@@ -274,6 +274,10 @@ say_logger_init(const char *init_str,
const char *log_format,
int background);
+/** Test if logger is initialized. */
+bool
+say_logger_initialized(void);
+
/** Free default logger */
void
say_logger_free();
--
2.26.2
More information about the Tarantool-patches
mailing list