From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 511D545BC3; Thu, 24 Oct 2024 21:09:26 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6F59843593; Thu, 24 Oct 2024 21:08:48 +0200 (CEST) Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) by mails.dpdk.org (Postfix) with ESMTP id C5EEC4356A for ; Thu, 24 Oct 2024 21:08:37 +0200 (CEST) Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-20ca1b6a80aso12449145ad.2 for ; Thu, 24 Oct 2024 12:08:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1729796917; x=1730401717; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ro2AL9vcp+zvF+7kamRivm89bGGcKPfO0QK8pEB8AmA=; b=JMslJQx7BeB2fdcXxIgALrT9OlW4Vfeb7P+HD65iHBWpzGD+IJAh1IbfTxz9g5GtNy 1Nwh+3MxclmpW/b5TFEZQZIuIARWU1A0uajfWrWC0eFQNI61PeYNKIscK7YoX8fLMLJ9 yWDfY8+XqmkMFWrFevgDMsehiK4yfmQLef7+83NwoKYyZH8MMbe8VhqcK/OhTnxV4gCz Yh6cQkZB5QtvuA68e2a2Vy7rP+jVCzJ6q80b/n4inCptwOGvyt0Sfwnrm9FicuRpTgaK OrU4GR3qlk1HjKA8zKHKEAyHXlRw/VW//1gyiJPuvBDZB7nd7q29bPYHtZV0YpF51jRh wFbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729796917; x=1730401717; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ro2AL9vcp+zvF+7kamRivm89bGGcKPfO0QK8pEB8AmA=; b=FZXnmNwfe/5mbxTNeHYPzC/JDntR+x+BTRZwTLyZty5f23PpGTiEBrMH73QTCPzW8e o1EAWTZGmTAmeodvnf6rZ+OVd+0yhmzpWlJGjSLnNt0wU2alBSP4kudmDW6Rvtg1p+qL edDh383yXbkioTfJQ2K21+espBl0PkYsV6ybwVOX+yefVq264LXvaDTe5bxPjQJrouZg H5MvN3m0Ghx7VKunbLBki5f1ecwNiTxuzRmO9AduY2lH6bgexqDSLLXnYDhIz6DjZIXp FFd6lNah045ufoDQRr6aWhCHdNBfgpOWRnIcwpCTEHHrqlsVYnLQthRTDocyBWMcdFRG 925w== X-Gm-Message-State: AOJu0YwaYomJEIBUUo9SHlOU0H7K7ZFQ8JzRi8nY/0OcfUmzDAXMDpwC X+UqetIrzT2Vo4jPbl+0kBxx2yARWD4MaTx1JBRF9wy+VZu02wzQLne+4+a350Y/JBAHKHrcRf/ j X-Google-Smtp-Source: AGHT+IEEUC/pcHu839vMa3pIhO7snEWIh/jKDFMiDxbM6TviuTu5pkpG8sFbmG8TDQeQX0BIohEoXA== X-Received: by 2002:a17:902:f64a:b0:20c:5d05:69b4 with SMTP id d9443c01a7336-20fa9e8b17amr101008845ad.26.1729796916869; Thu, 24 Oct 2024 12:08:36 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20e7f0f364bsm75535385ad.264.2024.10.24.12.08.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2024 12:08:36 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , =?UTF-8?q?Morten=20Br=C3=B8rup?= , Bruce Richardson , Chengwen Feng Subject: [PATCH v28 09/13] log: add hook for printing log messages Date: Thu, 24 Oct 2024 12:02:55 -0700 Message-ID: <20241024190818.172863-10-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241024190818.172863-1-stephen@networkplumber.org> References: <20200814173441.23086-1-stephen@networkplumber.org> <20241024190818.172863-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org This is useful for when decorating log output for console or journal. Provide basic version in this patch. Signed-off-by: Stephen Hemminger Acked-by: Morten Brørup Acked-by: Bruce Richardson Acked-by: Chengwen Feng --- lib/log/log.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/log/log.c b/lib/log/log.c index feadcd6848..5e1eeb25c7 100644 --- a/lib/log/log.c +++ b/lib/log/log.c @@ -30,16 +30,21 @@ struct rte_log_dynamic_type { uint32_t loglevel; }; +/* Note: same as vfprintf() */ +typedef int (*log_print_t)(FILE *f, const char *fmt, va_list ap); + /** The rte_log structure. */ static struct rte_logs { uint32_t type; /**< Bitfield with enabled logs. */ uint32_t level; /**< Log level. */ FILE *file; /**< Output file set by rte_openlog_stream, or NULL. */ + log_print_t print_func; size_t dynamic_types_len; struct rte_log_dynamic_type *dynamic_types; } rte_logs = { .type = UINT32_MAX, .level = RTE_LOG_DEBUG, + .print_func = vfprintf, }; struct rte_eal_opt_loglevel { @@ -76,6 +81,7 @@ int rte_openlog_stream(FILE *f) { rte_logs.file = f; + rte_logs.print_func = vfprintf; return 0; } @@ -472,7 +478,7 @@ rte_vlog(uint32_t level, uint32_t logtype, const char *format, va_list ap) RTE_PER_LCORE(log_cur_msg).loglevel = level; RTE_PER_LCORE(log_cur_msg).logtype = logtype; - ret = vfprintf(f, format, ap); + ret = (*rte_logs.print_func)(f, format, ap); fflush(f); return ret; } -- 2.45.2