get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/138993/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 138993,
    "url": "http://patchwork.dpdk.org/api/patches/138993/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20240330030429.4630-14-stephen@networkplumber.org/",
    "project": {
        "id": 1,
        "url": "http://patchwork.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<20240330030429.4630-14-stephen@networkplumber.org>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20240330030429.4630-14-stephen@networkplumber.org",
    "date": "2024-03-30T03:00:56",
    "name": "[v19,13/15] log: add optional support of syslog",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "cf4d7d88123a5ff0483d41c1b8e645505f0c1b81",
    "submitter": {
        "id": 27,
        "url": "http://patchwork.dpdk.org/api/people/27/?format=api",
        "name": "Stephen Hemminger",
        "email": "stephen@networkplumber.org"
    },
    "delegate": {
        "id": 1,
        "url": "http://patchwork.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/20240330030429.4630-14-stephen@networkplumber.org/mbox/",
    "series": [
        {
            "id": 31647,
            "url": "http://patchwork.dpdk.org/api/series/31647/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=31647",
            "date": "2024-03-30T03:00:44",
            "name": "Logging unification and improvements",
            "version": 19,
            "mbox": "http://patchwork.dpdk.org/series/31647/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/138993/comments/",
    "check": "warning",
    "checks": "http://patchwork.dpdk.org/api/patches/138993/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 4772F43D8B;\n\tSat, 30 Mar 2024 04:06:12 +0100 (CET)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 4ADD742D89;\n\tSat, 30 Mar 2024 04:05:04 +0100 (CET)",
            "from mail-pf1-f180.google.com (mail-pf1-f180.google.com\n [209.85.210.180])\n by mails.dpdk.org (Postfix) with ESMTP id 0F92140A7A\n for <dev@dpdk.org>; Sat, 30 Mar 2024 04:04:52 +0100 (CET)",
            "by mail-pf1-f180.google.com with SMTP id\n d2e1a72fcca58-6e6b6f86975so1656906b3a.1\n for <dev@dpdk.org>; Fri, 29 Mar 2024 20:04:51 -0700 (PDT)",
            "from hermes.local (204-195-123-203.wavecable.com. [204.195.123.203])\n by smtp.gmail.com with ESMTPSA id\n o3-20020a056a00214300b006e6288ef4besm3655486pfk.54.2024.03.29.20.04.50\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Fri, 29 Mar 2024 20:04:50 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1711767891;\n x=1712372691; darn=dpdk.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=F08iCjqZi4sMXW/XVhSNwhyPFqam6Vw4whM/OZTQKzI=;\n b=uv7lnreS2IfPruUkeyBfw8mLWHK85Ci8ghKGR8XZ34UJrVLBBHxRoCp0rTuVUFwdXI\n Vx/BpOt2QJ14teEC/EVBdJnb3S8M39iGvlpDV5t1ZwoYjiDsqsVmyoJwgFbfdhvkoT1/\n WCaBBAgGDMijF8z++KJJb4KEdBiFs3qE8alqTVS/Wp9NbO3KbDf6rbV1F3qMsDb3yv4H\n fSLoc/5279KfKaSJwTAVTvfSHeZ8nc7DWsJuBqxg4TMdHt4aSKL9PLE3wFcLKyjCE601\n nZ6qN8+89r3lLsszyC6/pK023Dw/9a4lWiTF8tj9RmTLrtzHGdYVuRu5Wt+KiBTJdxgN\n 8+wA==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1711767891; x=1712372691;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n :subject:date:message-id:reply-to;\n bh=F08iCjqZi4sMXW/XVhSNwhyPFqam6Vw4whM/OZTQKzI=;\n b=fG5F8o39+vRJmBWhTxSFSjDi47ToKKJf3waXnjk1dXLUwyUohWj2ubGVAfVCB2I1eZ\n ONQMSVQGuFMHtRmL2CYn8H/mnWtifClByufbVEETfPnIuaeHF2WlP/KfjDP9FihkyyCw\n RVGtQYXZkoivgK+LeoX8dTkXqnE7f8T06DvO+0h+oFHKTj8kggykVojSadlrrcQxA8s8\n NB3t6+vhvo+VbZVT0M9BpaveCI9BJUqTE9/kFywlE3kf++PDe1KhHZ0aPIMS7KJuJnRD\n JUpWwknpcKqiQTauWJwG/vGzJw2Gy5l3NcKqrodPaKkHFV/VzEpn9WpWGiBth0MreXvx\n uG8w==",
        "X-Gm-Message-State": "AOJu0Yxjxw7FChEeP2NrKGg2ic8QHXgk5Qud1KatR+xRwsAlCivEQNhg\n LC9Asde4HahGSiNv+FGIRUK55vsUpOzUP+HUqHmXuSTSW4mGeH0tYfVi+DrQP2DjPS+72W1o4/5\n 4",
        "X-Google-Smtp-Source": "\n AGHT+IGENLTdtsrXv92w6NhQyqzrez+FugytV1zDhZuH2D8dDdowpxgV2jlwjffJpSF7hqe6RlftBg==",
        "X-Received": "by 2002:a05:6a21:1690:b0:1a6:fe1d:727f with SMTP id\n np16-20020a056a21169000b001a6fe1d727fmr3014595pzb.53.1711767891242;\n Fri, 29 Mar 2024 20:04:51 -0700 (PDT)",
        "From": "Stephen Hemminger <stephen@networkplumber.org>",
        "To": "dev@dpdk.org",
        "Cc": "Stephen Hemminger <stephen@networkplumber.org>",
        "Subject": "[PATCH v19 13/15] log: add optional support of syslog",
        "Date": "Fri, 29 Mar 2024 20:00:56 -0700",
        "Message-ID": "<20240330030429.4630-14-stephen@networkplumber.org>",
        "X-Mailer": "git-send-email 2.43.0",
        "In-Reply-To": "<20240330030429.4630-1-stephen@networkplumber.org>",
        "References": "<20200814173441.23086-1-stephen@networkplumber.org>\n <20240330030429.4630-1-stephen@networkplumber.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org"
    },
    "content": "Log to syslog only if option is specified. And if syslog is used\nthen normally only log to syslog, don't duplicate output.\nAlso enables syslog support on FreeBSD.\n\nSigned-off-by: Stephen Hemminger <stephen@networkplumber.org>\n---\n app/test/test_eal_flags.c                     |  5 +-\n doc/guides/linux_gsg/linux_eal_parameters.rst | 27 ------\n doc/guides/prog_guide/log_lib.rst             | 17 ++++\n lib/eal/common/eal_common_options.c           |  5 +-\n lib/log/log.c                                 | 25 +++---\n lib/log/log_private.h                         |  4 +\n lib/log/log_stubs.c                           | 28 ++++++\n lib/log/log_syslog.c                          | 89 +++++++++++++++++++\n lib/log/meson.build                           |  6 ++\n 9 files changed, 165 insertions(+), 41 deletions(-)\n create mode 100644 lib/log/log_stubs.c\n create mode 100644 lib/log/log_syslog.c",
    "diff": "diff --git a/app/test/test_eal_flags.c b/app/test/test_eal_flags.c\nindex e54f6e8b7f..08f4866461 100644\n--- a/app/test/test_eal_flags.c\n+++ b/app/test/test_eal_flags.c\n@@ -987,9 +987,10 @@ test_misc_flags(void)\n \t/* With empty --syslog */\n \tconst char *argv3[] = {prgname, prefix, mp_flag, \"--syslog\"};\n \t/* With valid --syslog */\n-\tconst char *argv4[] = {prgname, prefix, mp_flag, \"--syslog\", \"always\"};\n+\tconst char *argv4[] = {prgname, prefix, mp_flag, \"--syslog=both\"};\n \t/* With invalid --syslog */\n-\tconst char *argv5[] = {prgname, prefix, mp_flag, \"--syslog\", \"error\"};\n+\tconst char *argv5[] = {prgname, prefix, mp_flag, \"--syslog=invalid\"};\n+\n \t/* With no-sh-conf, also use no-huge to ensure this test runs on BSD */\n \tconst char *argv6[] = {prgname, \"-m\", DEFAULT_MEM_SIZE,\n \t\t\tno_shconf, nosh_prefix, no_huge};\ndiff --git a/doc/guides/linux_gsg/linux_eal_parameters.rst b/doc/guides/linux_gsg/linux_eal_parameters.rst\nindex ea8f381391..d86f94d8a8 100644\n--- a/doc/guides/linux_gsg/linux_eal_parameters.rst\n+++ b/doc/guides/linux_gsg/linux_eal_parameters.rst\n@@ -108,30 +108,3 @@ Memory-related options\n *   ``--match-allocations``\n \n     Free hugepages back to system exactly as they were originally allocated.\n-\n-Other options\n-~~~~~~~~~~~~~\n-\n-*   ``--syslog <syslog facility>``\n-\n-    Set syslog facility. Valid syslog facilities are::\n-\n-        auth\n-        cron\n-        daemon\n-        ftp\n-        kern\n-        lpr\n-        mail\n-        news\n-        syslog\n-        user\n-        uucp\n-        local0\n-        local1\n-        local2\n-        local3\n-        local4\n-        local5\n-        local6\n-        local7\ndiff --git a/doc/guides/prog_guide/log_lib.rst b/doc/guides/prog_guide/log_lib.rst\nindex 504eefe1d2..abaedc7212 100644\n--- a/doc/guides/prog_guide/log_lib.rst\n+++ b/doc/guides/prog_guide/log_lib.rst\n@@ -83,6 +83,23 @@ To prefix all console messages with ISO format time the syntax is::\n \n \t/path/to/app --log-timestamp=iso\n \n+Log output\n+~~~~~~~~~~\n+\n+If desired, messages can be redirected to syslog (on Linux and FreeBSD) with the ``--syslog``\n+option. There are three possible settings for this option:\n+\n+*always*\n+    Redirect all log output to syslog.\n+\n+*auto*\n+    Use console if it is a terminal, and use syslog if is not.\n+\n+*both*\n+    Print to both console and syslog.\n+\n+If ``--syslog`` option is not specified, then only console (stderr) will be used.\n+\n \n \n Using Logging APIs to Generate Log Messages\ndiff --git a/lib/eal/common/eal_common_options.c b/lib/eal/common/eal_common_options.c\nindex 5173835c2c..9ca7db04aa 100644\n--- a/lib/eal/common/eal_common_options.c\n+++ b/lib/eal/common/eal_common_options.c\n@@ -91,7 +91,7 @@ eal_long_options[] = {\n \t{OPT_PROC_TYPE,         1, NULL, OPT_PROC_TYPE_NUM        },\n \t{OPT_SOCKET_MEM,        1, NULL, OPT_SOCKET_MEM_NUM       },\n \t{OPT_SOCKET_LIMIT,      1, NULL, OPT_SOCKET_LIMIT_NUM     },\n-\t{OPT_SYSLOG,            1, NULL, OPT_SYSLOG_NUM           },\n+\t{OPT_SYSLOG,            2, NULL, OPT_SYSLOG_NUM           },\n \t{OPT_VDEV,              1, NULL, OPT_VDEV_NUM             },\n \t{OPT_VFIO_INTR,         1, NULL, OPT_VFIO_INTR_NUM        },\n \t{OPT_VFIO_VF_TOKEN,     1, NULL, OPT_VFIO_VF_TOKEN_NUM    },\n@@ -2221,6 +2221,9 @@ eal_common_usage(void)\n \t       \"                      (can be used multiple times)\\n\"\n \t       \"  --\"OPT_VMWARE_TSC_MAP\"    Use VMware TSC map instead of native RDTSC\\n\"\n \t       \"  --\"OPT_PROC_TYPE\"         Type of this process (primary|secondary|auto)\\n\"\n+#ifndef RTE_EXEC_ENV_WINDOWS\n+\t       \"  --\"OPT_SYSLOG\"[=<when>]   Enable use of syslog\\n\"\n+#endif\n \t       \"  --\"OPT_LOG_LEVEL\"=<level> Set global log level\\n\"\n \t       \"  --\"OPT_LOG_LEVEL\"=<type-match>:<level>\\n\"\n \t       \"                      Set specific log level\\n\"\ndiff --git a/lib/log/log.c b/lib/log/log.c\nindex 3c15f2a560..ddb8400d73 100644\n--- a/lib/log/log.c\n+++ b/lib/log/log.c\n@@ -12,18 +12,19 @@\n #include <regex.h>\n #include <fnmatch.h>\n #include <sys/queue.h>\n+#include <unistd.h>\n \n #include <rte_common.h>\n #include <rte_log.h>\n #include <rte_per_lcore.h>\n \n-#include \"log_internal.h\"\n-#include \"log_private.h\"\n-\n #ifdef RTE_EXEC_ENV_WINDOWS\n #include <rte_os_shim.h>\n #endif\n \n+#include \"log_internal.h\"\n+#include \"log_private.h\"\n+\n struct rte_log_dynamic_type {\n \tconst char *name;\n \tuint32_t loglevel;\n@@ -496,13 +497,6 @@ rte_log(uint32_t level, uint32_t logtype, const char *format, ...)\n \treturn ret;\n }\n \n-/* Placeholder */\n-int\n-eal_log_syslog(const char *mode __rte_unused)\n-{\n-\treturn -1;\n-}\n-\n /* default log print function */\n int\n log_print(FILE *f, uint32_t level __rte_unused,  const char *format, va_list ap)\n@@ -514,8 +508,17 @@ log_print(FILE *f, uint32_t level __rte_unused,  const char *format, va_list ap)\n  * Called by rte_eal_init\n  */\n void\n-eal_log_init(const char *id __rte_unused)\n+eal_log_init(const char *id)\n {\n+#ifdef RTE_EXEC_ENV_WINDOWS\n+\tRTE_SET_USED(id);\n+#else\n+\tbool is_terminal = isatty(STDERR_FILENO);\n+\n+\tif (log_syslog_enabled(is_terminal))\n+\t\tlog_syslog_open(id, is_terminal);\n+\telse\n+#endif\n \tif (log_timestamp_enabled())\n \t\trte_logs.print_func = log_print_with_timestamp;\n \telse\ndiff --git a/lib/log/log_private.h b/lib/log/log_private.h\nindex 070baee8dd..0e7d10ffca 100644\n--- a/lib/log/log_private.h\n+++ b/lib/log/log_private.h\n@@ -15,4 +15,8 @@ ssize_t log_timestamp(char *tsbuf, size_t tsbuflen);\n __rte_format_printf(3, 0)\n int log_print_with_timestamp(FILE *f, uint32_t level, const char *format, va_list ap);\n \n+bool log_syslog_enabled(bool is_tty);\n+void log_syslog_open(const char *id, bool is_terminal);\n+\n+\n #endif /* LOG_PRIVATE_H */\ndiff --git a/lib/log/log_stubs.c b/lib/log/log_stubs.c\nnew file mode 100644\nindex 0000000000..cb34217af8\n--- /dev/null\n+++ b/lib/log/log_stubs.c\n@@ -0,0 +1,28 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2010-2014 Intel Corporation\n+ */\n+\n+#include <stdio.h>\n+#include <stdint.h>\n+#include <stdarg.h>\n+#include <stdlib.h>\n+#include <string.h>\n+#include <errno.h>\n+#include <regex.h>\n+#include <fnmatch.h>\n+#include <sys/queue.h>\n+#include <unistd.h>\n+#include <rte_os_shim.h>\n+\n+#include <rte_log.h>\n+#include <rte_per_lcore.h>\n+\n+#include \"log_internal.h\"\n+#include \"log_private.h\"\n+\n+/* Stubs for Windows */\n+int\n+eal_log_syslog(const char *str __rte_unused)\n+{\n+\treturn -1;\n+}\ndiff --git a/lib/log/log_syslog.c b/lib/log/log_syslog.c\nnew file mode 100644\nindex 0000000000..33eff3a1cf\n--- /dev/null\n+++ b/lib/log/log_syslog.c\n@@ -0,0 +1,89 @@\n+/* SPDX-License-Identifier: BSD-3-Clause */\n+#include <stdbool.h>\n+#include <stdio.h>\n+#include <string.h>\n+#include <syslog.h>\n+\n+#include <rte_common.h>\n+#include <rte_log.h>\n+\n+#include \"log_internal.h\"\n+#include \"log_private.h\"\n+\n+static enum {\n+\tLOG_SYSLOG_NONE = 0,\t/* do not use syslog */\n+\tLOG_SYSLOG_AUTO,\t/* use syslog only if not a terminal */\n+\tLOG_SYSLOG_ALWAYS,\t/* always use syslog */\n+\tLOG_SYSLOG_BOTH,\t/* log to both syslog and stderr */\n+} log_syslog_opt;\n+\n+int\n+eal_log_syslog(const char *str)\n+{\n+\tif (str == NULL || strcmp(str, \"auto\") == 0)\n+\t\tlog_syslog_opt = LOG_SYSLOG_AUTO;\n+\telse if (strcmp(str, \"both\") == 0)\n+\t\tlog_syslog_opt = LOG_SYSLOG_BOTH;\n+\telse if (strcmp(str, \"always\") == 0)\n+\t\tlog_syslog_opt = LOG_SYSLOG_ALWAYS;\n+\telse\n+\t\treturn -1;\n+\treturn 0;\n+}\n+\n+bool\n+log_syslog_enabled(bool is_terminal)\n+{\n+\tswitch (log_syslog_opt) {\n+\tdefault:\n+\t\treturn false;\n+\n+\tcase LOG_SYSLOG_ALWAYS:\n+\tcase LOG_SYSLOG_BOTH:\n+\t\treturn true;\n+\n+\tcase LOG_SYSLOG_AUTO:\n+\t\treturn !is_terminal;\n+\t}\n+}\n+\n+/*\n+ * wrapper for log stream to put messages into syslog\n+ * useful for cases like:\n+ *   rte_hex_dump(rte_get_log_stream(), ...)\n+ */\n+static ssize_t\n+syslog_log_write(__rte_unused void *c, const char *buf, size_t size)\n+{\n+\t/* Syslog error levels are from 0 to 7, so subtract 1 to convert */\n+\tsyslog(rte_log_cur_msg_loglevel() - 1, \"%.*s\", (int)size, buf);\n+\treturn size;\n+}\n+\n+static int\n+syslog_log_close(__rte_unused void *c)\n+{\n+\tcloselog();\n+\treturn 0;\n+}\n+\n+static cookie_io_functions_t syslog_log_func = {\n+\t.write = syslog_log_write,\n+\t.close = syslog_log_close,\n+};\n+\n+void\n+log_syslog_open(const char *id, bool is_terminal)\n+{\n+\tint flags = LOG_NDELAY | LOG_PID;\n+\n+\tif (log_syslog_opt == LOG_SYSLOG_BOTH)\n+\t\tflags |= LOG_PERROR;\n+\n+\topenlog(id, flags, is_terminal ? LOG_USER : LOG_DAEMON);\n+\n+\t/* redirect other log messages to syslog as well */\n+\tFILE *log_stream = fopencookie(NULL, \"w\", syslog_log_func);\n+\tif (log_stream != NULL)\n+\t\trte_openlog_stream(log_stream);\n+}\ndiff --git a/lib/log/meson.build b/lib/log/meson.build\nindex 04235f6ee5..37507299e7 100644\n--- a/lib/log/meson.build\n+++ b/lib/log/meson.build\n@@ -7,4 +7,10 @@ sources = files(\n         'log_timestamp.c',\n )\n \n+if is_windows\n+\tsources += files('log_stubs.c')\n+else\n+\tsources += files('log_syslog.c')\n+endif\n+\n headers = files('rte_log.h')\n",
    "prefixes": [
        "v19",
        "13/15"
    ]
}