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 65B4445BF5; Sun, 27 Oct 2024 18:27:24 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BBA1B40A6B; Sun, 27 Oct 2024 18:26:44 +0100 (CET) Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by mails.dpdk.org (Postfix) with ESMTP id F205740650 for ; Sun, 27 Oct 2024 18:26:34 +0100 (CET) Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-20bb39d97d1so27232855ad.2 for ; Sun, 27 Oct 2024 10:26:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1730049994; x=1730654794; 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=f8gkTRV+sHFjeAIMhTG3V8MjFfnXJ/9FyExCQWUwmRhiEhfHg1fX0rlYtT+jJ8T8dq hMMipmTD3vZtGo7UqzjFXJL3cBZMN3ZsXRRg3gXFXA5/Qzarj219faEL1ZJ2dFyR0xe7 H30gsH3MSEpkToy7lVHNyodAdSElewsfw16d/fARnPi7mEWjgv/A09kw9hdhBf5WxRXh Z4o1HkoW5lnS3X6bH1J8NCaRLrbdpSWUyaVM7z/HHYRM2X+0tsYEmAAhdH+FS5A/Z4zr wc0ust+YPikLHn9+ebcU1k3A/u+NbNM5iXwIpsZexdbgzeexJ2JmaH3pW0D83p+YwUmy 3p/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730049994; x=1730654794; 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=C83zTUtm94YN+8h57R84UuOT8tcXmUR34k3pb2VkpzkG1PWZFmZQ7qDwj6KzokhIIV heDBiQG5EUlzjNNfV2P+u6T/RTSOC9+v0YRw+sj9kwmT7aOfuSVhoRwRqgN6w6TE0qI2 KcEGrfeiFm866L1LEztUlt4V/MJxXb1dbqFZa6xnsILmt9MPwYQpUKm8FO9uByZg5CtZ QpQ3AVnApBYFIRNwHmKc70d2SDFBOowmxJ2bVhcDGtIrpX22NgVF5v3mUmxVDRmJ568u 4bXnDutJMBQMh4Nb2/o+pL1wMLMXbIncZomXiVaqlObtuMYTIJOpbnVgngmjRy67U/ut /csw== X-Gm-Message-State: AOJu0Yy+gMUS65ChP3yh4afwjRvLDApSShT0jjwVZBERbYonw5U8MRHZ b5yVbDh2zAGlZTOwXqnQepKkXFnBjrTx0liRKZgIFiTvN22lWtKertRP2UMVpad5vfljilPpHIi EufBasg== X-Google-Smtp-Source: AGHT+IFcS7yQhzyXVSNW5M9MX6Ngyx2e2Xqu1Vt1WwXxs+6im//nnmJrefcus+0xWsqL1Pthi8mKhw== X-Received: by 2002:a17:903:234a:b0:20c:c88b:511b with SMTP id d9443c01a7336-210c6c1e203mr70611705ad.33.1730049994114; Sun, 27 Oct 2024 10:26:34 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-210bbf71d50sm37754465ad.72.2024.10.27.10.26.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Oct 2024 10:26:33 -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 v30 09/13] log: add hook for printing log messages Date: Sun, 27 Oct 2024 10:24:39 -0700 Message-ID: <20241027172616.176175-10-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241027172616.176175-1-stephen@networkplumber.org> References: <20200814173441.23086-1-stephen@networkplumber.org> <20241027172616.176175-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