From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-f193.google.com (mail-lj1-f193.google.com [209.85.208.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 78BF94696C0 for ; Wed, 27 May 2020 14:14:45 +0300 (MSK) Received: by mail-lj1-f193.google.com with SMTP id v16so28445449ljc.8 for ; Wed, 27 May 2020 04:14:45 -0700 (PDT) From: Cyrill Gorcunov Date: Wed, 27 May 2020 14:13:59 +0300 Message-Id: <20200527111406.145422-4-gorcunov@gmail.com> In-Reply-To: <20200527111406.145422-1-gorcunov@gmail.com> References: <20200527111406.145422-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v3 03/10] core/say: do not reconfig early set up logger List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tml 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 Signed-off-by: Cyrill Gorcunov --- 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