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 AC08545B88; Fri, 25 Oct 2024 23:47:36 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5342440B8F; Fri, 25 Oct 2024 23:46:56 +0200 (CEST) Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) by mails.dpdk.org (Postfix) with ESMTP id 08F3E402E3 for ; Fri, 25 Oct 2024 23:46:49 +0200 (CEST) Received: by mail-pj1-f52.google.com with SMTP id 98e67ed59e1d1-2e2a999b287so1982553a91.0 for ; Fri, 25 Oct 2024 14:46:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1729892808; x=1730497608; 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=YYeBUJxzlz0gxuzqxooMY6YuY5Q/B5JUEtef4Z+Fs2k=; b=ktuePLANaw8XJVw4C7TpSxrm0djXXBKsJQ2cV87rMQwJ4BoY8Myb9NXqkXKwKdEdoz p4v8wmv3mhnRV9I70nKDTl5+8Ok3hEZqpUdDpiU3jvwW8D/NncS2t/v4yYOnfchPj5z0 6zpQWyttN9CDiqVde0WEdtgPvrCQ5hOKB3uQ9vRerv27u5XLjAUiwYAOw+NNvvvORuYz t+00nCzrGlqzdVP/BSPRI8lelkYMSSiVz/UhxzGi2xcPg7vsdgHmzVNDDjaL5F9uOnKI KDgaIbw4Lfx/LhDlvhaydWnZXHA2nxdpqsTGEJEXPfkToEMRwHdTuCPOj05HsI3zK/SV 9jQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729892808; x=1730497608; 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=YYeBUJxzlz0gxuzqxooMY6YuY5Q/B5JUEtef4Z+Fs2k=; b=vgduzwIfAFgGrKifVoCnG5IEt52bU90cBXvGp/GtXpnWddf2hAHLFNYtbuZ/dWt2s9 jGk4dtoNbsbKvhdrQrg3zTjLiwDsqAwuc5AoBgTpKsDvX8v7/SRmHxrbBeNQ2lLmj7V5 Emg8Qdg8YalcJqfiRKinXoulj0NbUEFg+J3Dk3sIUORsuYoMwq3+QCv9gKxACazLcu6O /jVLc2IxL50Sx6Q+nT8UJhOc5yLZ9mWuZrpDsyGa4byZyZahjuUh4okiH+REXQgQiXd3 /LMKpRC+lvFMhXxAPa/lU72WsJBXJzfqtAc7NBOR1Z+lfe8d8JJT9DzmqdX7EKhWbKWt Md1A== X-Gm-Message-State: AOJu0YwpwPT9dic1VSolh69oI5nte/t9sqvqYp8cCAfU0I/DW2LNOBMK xqlS3x7A15L/iMaUo0liPdDn0anTDey7RuYVFLkWojSfeHiPhYvj/TLH0GAwC6Y6EkdeHB4li6q G X-Google-Smtp-Source: AGHT+IEu4Kx58KxvVw2YjuxIvKKrxMtIX4iZAkNjmwRvuQ4ULuJm0MLvg5T8KAaE9bPLMhrXk13wog== X-Received: by 2002:a17:90a:ba8f:b0:2d8:a744:a820 with SMTP id 98e67ed59e1d1-2e8f11b96a2mr930098a91.36.1729892808193; Fri, 25 Oct 2024 14:46:48 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e77e4c9c1bsm4049934a91.19.2024.10.25.14.46.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 14:46:47 -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 v29 09/13] log: add hook for printing log messages Date: Fri, 25 Oct 2024 14:45:14 -0700 Message-ID: <20241025214625.62876-10-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241025214625.62876-1-stephen@networkplumber.org> References: <20200814173441.23086-1-stephen@networkplumber.org> <20241025214625.62876-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 511ab3b30b..cc0c61cb22 100644 --- a/lib/log/log.c +++ b/lib/log/log.c @@ -29,16 +29,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 { @@ -75,6 +80,7 @@ int rte_openlog_stream(FILE *f) { rte_logs.file = f; + rte_logs.print_func = vfprintf; return 0; } @@ -471,7 +477,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