From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-f195.google.com (mail-lj1-f195.google.com [209.85.208.195]) (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 808BA4696C1 for ; Mon, 25 May 2020 15:17:54 +0300 (MSK) Received: by mail-lj1-f195.google.com with SMTP id b6so20551633ljj.1 for ; Mon, 25 May 2020 05:17:54 -0700 (PDT) From: Cyrill Gorcunov Date: Mon, 25 May 2020 15:17:08 +0300 Message-Id: <20200525121715.21216-4-gorcunov@gmail.com> In-Reply-To: <20200525121715.21216-1-gorcunov@gmail.com> References: <20200525121715.21216-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 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 Cc: Alexander Turenko 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