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 6532B45BB9; Thu, 24 Oct 2024 05:21:39 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3C86543392; Thu, 24 Oct 2024 05:20:56 +0200 (CEST) Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) by mails.dpdk.org (Postfix) with ESMTP id B37314336F for ; Thu, 24 Oct 2024 05:20:45 +0200 (CEST) Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-71e6cec7227so386793b3a.0 for ; Wed, 23 Oct 2024 20:20:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1729740045; x=1730344845; 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=tMsgnKLH/mkId9FBShUVHoIagprWeJ+NJGmJvt30wGc=; b=GfiCtRly+zLzD7ISGMy8RjuZ95xFa87pCi8FvCM2eztFY1ocsm0NWhYfyB4VdEN8TJ e+nJXmzxP5Ptq3HwUTxp/l2/XYOZ/fmmSShjVVVYBcZ9uMGDVed/QblNJG2d3Vg7pRmK 4IEukpUGjpK2srpIv8eFd8NFa5nwWZapGJpdHjtvNHBE7drDaEv5VHkSGVJXck4xkzMk w/w/NxdgU1kQW7mBPETe5Z1vrL09KBTJrvWx4YQcKJRJruVV5X5LjhxXk8Fcq9ouKlQu 483YvrJ2NvqRODtvJzOKjzH7VfTl8IU9xZs7QlpNyVmzUOU1AbR5Kqyx5u5p9UhsLSn5 gBlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729740045; x=1730344845; 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=tMsgnKLH/mkId9FBShUVHoIagprWeJ+NJGmJvt30wGc=; b=dN/kQv7SKnRhp1fGnnUAYe1W2pk9OtOsC0/7MzHMO6zV0y+8pCCyQ/kT7O2ezVWMqX aGEX+BgMnjd/K41UXmUv9Pv4JYSjpQpX2ZK1vPwwxeYksmQ8r/NtezQYetk0y+5fzyEm FWu7hRrU6VcZBTANAjm82wG2cwzzZiwN9UYfe0w4XjB9lNT8uV8b8WS3H0Ogn+kogaSu g2L4SYnRoV+EkbXbMK0c4g0BLRCPQ/54rbMhIBN7KV+rg52eqJQxs42FOhYL29VJwAKm xlXuURAif4yjiAKlUuyJTfsD9dWEzYIKurAZ1DVikf/lt/gXp5vRHMDhJTnJT0cC66cn B4rA== X-Gm-Message-State: AOJu0YyaND1jtiK55Ekz/kY11PSnEGrH8ZH0ZIasWh8m1v3cfaCmVoQg AKR9AzfcO4+BrDOl7YJzDijNtfaDTjHjg+KfDbumu04YPsAgF0Sr+QN2ES4u0KoEHoMKd8edwv6 j X-Google-Smtp-Source: AGHT+IE6VKAFkMX5JgVjzQX4Tzy/l3hFbBJk8RHNtdc2mj3qv72ueHVbqZEhzE+q9P+wq3zJVT8RlQ== X-Received: by 2002:a05:6a00:b50:b0:70b:176e:b3bc with SMTP id d2e1a72fcca58-72045f8a518mr643203b3a.28.1729740044872; Wed, 23 Oct 2024 20:20:44 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71ec1324d41sm6999533b3a.57.2024.10.23.20.20.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2024 20:20:44 -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 v27 09/14] log: add hook for printing log messages Date: Wed, 23 Oct 2024 20:18:47 -0700 Message-ID: <20241024032026.415122-10-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241024032026.415122-1-stephen@networkplumber.org> References: <20200814173441.23086-1-stephen@networkplumber.org> <20241024032026.415122-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 d41ca2ed31..152aa634c7 100644 --- a/lib/log/log.c +++ b/lib/log/log.c @@ -27,16 +27,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 { @@ -78,6 +83,7 @@ int rte_openlog_stream(FILE *f) { rte_logs.file = f; + rte_logs.print_func = vfprintf; return 0; } @@ -484,7 +490,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