get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 138761,
    "url": "http://patchwork.dpdk.org/api/patches/138761/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20240324024109.306614-9-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": "<20240324024109.306614-9-stephen@networkplumber.org>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20240324024109.306614-9-stephen@networkplumber.org",
    "date": "2024-03-24T02:33:30",
    "name": "[v11,8/9] log: add support for systemd journal",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "3a2d0af1ff56fd9da05da6a28ba188068fc08775",
    "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/20240324024109.306614-9-stephen@networkplumber.org/mbox/",
    "series": [
        {
            "id": 31607,
            "url": "http://patchwork.dpdk.org/api/series/31607/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=31607",
            "date": "2024-03-24T02:33:22",
            "name": "Logging unification and enhancements",
            "version": 11,
            "mbox": "http://patchwork.dpdk.org/series/31607/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/138761/comments/",
    "check": "warning",
    "checks": "http://patchwork.dpdk.org/api/patches/138761/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 6CEA643D36;\n\tSun, 24 Mar 2024 03:42:22 +0100 (CET)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 08B89406B8;\n\tSun, 24 Mar 2024 03:41:34 +0100 (CET)",
            "from mail-pl1-f171.google.com (mail-pl1-f171.google.com\n [209.85.214.171])\n by mails.dpdk.org (Postfix) with ESMTP id 5A08E402EC\n for <dev@dpdk.org>; Sun, 24 Mar 2024 03:41:27 +0100 (CET)",
            "by mail-pl1-f171.google.com with SMTP id\n d9443c01a7336-1e034607879so25623615ad.0\n for <dev@dpdk.org>; Sat, 23 Mar 2024 19:41:27 -0700 (PDT)",
            "from hermes.local (204-195-123-203.wavecable.com. [204.195.123.203])\n by smtp.gmail.com with ESMTPSA id\n q17-20020a17090311d100b001dc3c4e7a12sm2244980plh.14.2024.03.23.19.41.26\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Sat, 23 Mar 2024 19:41:26 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1711248086;\n x=1711852886; 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=LCYp3m42AR3Bl02fdCxypzjKxWlwIQYVWzlmXEvqwJo=;\n b=taSHpVp6ukoNZ58mie4uRfNcPRx2b4/Ts8/x3i5VS9xXxdztmpR3u7BTYq7RILS49M\n KeKv+1Dowf1ZSsjtQBHI9UkpkZZ7ewbEuWiMOcp7UsRQ4l4oAkgDUXsKDXj8/y2tq1n2\n ynkCUa0HBgHgxXV3t2V3Kt9miYlZr97Mz7AjOk3Z1CIeCZoRnZhWd6Mitx6+Cd4I6ox1\n dxwBxvUVlLhNmFHRHaIAP8uXuy2sl1PtBxVgZhfcTCaEw3KV61VCfUzmoS6V5+yFr7H/\n +5C8k+yqlw4IvwpsoA4uBKojlLb8jzERX/cL7B9FLrdo7uQ3YhlXyfp358+jbM+qbbz+\n te1A==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1711248086; x=1711852886;\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=LCYp3m42AR3Bl02fdCxypzjKxWlwIQYVWzlmXEvqwJo=;\n b=mljAY7rwuh5WgABwt2BxboQiO+aSK9NMkA5qf+whQ0Az87SH9i7YLywsqBttjB0idz\n r1Ynkb0xl5wV+CfaVDA/0/AJk/Qwk+qGT0tCG5QIO600iF0NTKcY4kxP3gtjoPzdIVx9\n 2G6zKGvYw8DvUeFCoZk6Vtaqd2o4+jEWEnp/NCux1n2z5OvXEG7p0R6UFmnEdaC/2mTe\n ra3nsSQ1UWqXteU8O5nwytSH13FJiW8l6oJD9TbBoY/FJjflAKKrBMgJi2JnYqanzriM\n pqC0j1Vd3PiOWnR8dxh7ToofTSIWorgr3xTU5PVkpT0pC8zFCKsO6GxZcrMzPDBAaBQ4\n vCtw==",
        "X-Gm-Message-State": "AOJu0YywQ/Em0Is0WhgKwn/nWtmXvwn75+fZwzNPUTB/MhFHMpfsFwKt\n c6f1KNb89ZOUjBNtwUlHfkvh25zVshqerot6LSHFejYeoKRZf6q59e4ydLqjtuITFUcSXXr/bcS\n d",
        "X-Google-Smtp-Source": "\n AGHT+IF7XgmNXk8AH99VyNhqznazLQIcdk/PHeLl9qAd7uj56dqWdFRVNuCI5Bk42WTi6n2tq/RsQw==",
        "X-Received": "by 2002:a17:903:186:b0:1dd:7df8:9ed7 with SMTP id\n z6-20020a170903018600b001dd7df89ed7mr5526206plg.15.1711248086613;\n Sat, 23 Mar 2024 19:41:26 -0700 (PDT)",
        "From": "Stephen Hemminger <stephen@networkplumber.org>",
        "To": "dev@dpdk.org",
        "Cc": "Stephen Hemminger <stephen@networkplumber.org>",
        "Subject": "[PATCH v11 8/9] log: add support for systemd journal",
        "Date": "Sat, 23 Mar 2024 19:33:30 -0700",
        "Message-ID": "<20240324024109.306614-9-stephen@networkplumber.org>",
        "X-Mailer": "git-send-email 2.43.0",
        "In-Reply-To": "<20240324024109.306614-1-stephen@networkplumber.org>",
        "References": "<20200814173441.23086-1-stephen@networkplumber.org>\n <20240324024109.306614-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": "If DPDK application is being run as a systemd service, then\nit can use the journal protocol which allows putting more information\nin the log such as priority and other information.\n\nThe use of journal protocol is automatically detected and\nhandled.  Rather than having a dependency on libsystemd,\njust use the protocol directly as defined in:\n\thttps://systemd.io/JOURNAL_NATIVE_PROTOCOL/\n\nThe journal protocol supports more information that could\nbe added later.\n\nSigned-off-by: Stephen Hemminger <stephen@networkplumber.org>\n---\n lib/log/log.c | 141 ++++++++++++++++++++++++++++++++++++++++++++++++--\n 1 file changed, 136 insertions(+), 5 deletions(-)",
    "diff": "diff --git a/lib/log/log.c b/lib/log/log.c\nindex bd488dff1b..4cfa160e3b 100644\n--- a/lib/log/log.c\n+++ b/lib/log/log.c\n@@ -13,15 +13,20 @@\n #include <sys/queue.h>\n #include <unistd.h>\n \n+#ifdef RTE_EXEC_ENV_WINDOWS\n+#include <rte_os_shim.h>\n+#else\n+#include <sys/uio.h>\n+#include <sys/stat.h>\n+#include <sys/socket.h>\n+#include <sys/un.h>\n+#endif\n+\n #include <rte_log.h>\n #include <rte_per_lcore.h>\n \n #include \"log_internal.h\"\n \n-#ifdef RTE_EXEC_ENV_WINDOWS\n-#include <rte_os_shim.h>\n-#endif\n-\n struct rte_log_dynamic_type {\n \tconst char *name;\n \tuint32_t loglevel;\n@@ -39,11 +44,13 @@ enum eal_log_time_format {\n typedef int (*log_print_t)(FILE *f, uint32_t level, const char *fmt, va_list ap);\n static int log_print(FILE *f, uint32_t level, const char *format, va_list ap);\n \n+\n /** The rte_log structure. */\n static struct rte_logs {\n \tuint32_t type;  /**< Bitfield with enabled logs. */\n \tuint32_t level; /**< Log level. */\n \tFILE *file;     /**< Output file set by rte_openlog_stream, or NULL. */\n+\tint journal_fd;\t/**< Journal file descriptor if using */\n \tlog_print_t print_func;\n \n \tenum eal_log_time_format time_format;\n@@ -681,6 +688,116 @@ log_print_with_timestamp(FILE *f, uint32_t level,\n \treturn log_print(f, level, format, ap);\n }\n \n+#ifdef RTE_EXEC_ENV_LINUX\n+/*\n+ * send message using journal protocol to journald\n+ */\n+__rte_format_printf(3, 0)\n+static int\n+journal_print(FILE *f __rte_unused, uint32_t level, const char *format, va_list ap)\n+{\n+\tstruct iovec iov[3];\n+\tchar *buf = NULL;\n+\tsize_t len;\n+\tchar msg[] = \"MESSAGE=\";\n+\tchar *prio;\n+\n+\tiov[0].iov_base = msg;\n+\tiov[0].iov_len = strlen(msg);\n+\n+\tlen = vasprintf(&buf, format, ap);\n+\tif (len == 0)\n+\t\treturn 0;\n+\n+\t/* check that message ends with newline */\n+\tif (buf[len - 1] != '\\n') {\n+\t\tchar *clone  = alloca(len + 1);\n+\t\tif (clone == NULL)\n+\t\t\treturn 0;\n+\t\tmemcpy(clone, buf, len);\n+\t\tclone[len++] = '\\n';\n+\t\tbuf = clone;\n+\t}\n+\n+\tiov[1].iov_base = buf;\n+\tiov[1].iov_len = len;\n+\n+\t/* priority value between 0 (\"emerg\") and 7 (\"debug\") */\n+\tlen = asprintf(&prio, \"PRIORITY=%i\\n\", level - 1);\n+\tiov[2].iov_base = prio;\n+\tiov[2].iov_len = len;\n+\n+\treturn writev(rte_logs.journal_fd, iov, 3);\n+}\n+\n+static void\n+journal_send_id(int fd, const char *id)\n+{\n+\tchar *syslog_id = NULL;\n+\tsize_t len;\n+\n+\tlen = asprintf(&syslog_id, \"SYSLOG_IDENTIFIER=%s\\n\", id);\n+\tif (len > 0)\n+\t\twrite(fd, syslog_id, len);\n+\n+}\n+\n+/*\n+ * Check if stderr is going to system journal.\n+ * This is the documented way to handle systemd journal\n+ *\n+ * See: https://systemd.io/JOURNAL_NATIVE_PROTOCOL/\n+ *\n+ */\n+static bool\n+using_journal(void)\n+{\n+\tchar *jenv, *endp = NULL;\n+\tstruct stat st;\n+\tunsigned long dev, ino;\n+\n+\tjenv = getenv(\"JOURNAL_STREAM\");\n+\tif (jenv == NULL)\n+\t\treturn false;\n+\n+\tif (fstat(STDERR_FILENO, &st) < 0)\n+\t\treturn false;\n+\n+\t/* systemd sets colon-separated list of device and inode number */\n+\tdev = strtoul(jenv, &endp, 10);\n+\tif (endp == NULL || *endp != ':')\n+\t\treturn false;\t/* missing colon */\n+\n+\tino = strtoul(endp + 1, NULL, 10);\n+\n+\treturn dev == st.st_dev && ino == st.st_ino;\n+}\n+\n+/*\n+ * If we are being run as systemd service and stderr is going to journal\n+ * then upgrade to use journal protocol.\n+ */\n+static int\n+open_journal(void)\n+{\n+\tstruct sockaddr_un sun = {\n+\t\t.sun_family = AF_UNIX,\n+\t\t.sun_path = \"/run/systemd/journal/socket\",\n+\t};\n+\tint s;\n+\n+\ts = socket(AF_UNIX, SOCK_DGRAM, 0);\n+\tif (s < 0)\n+\t\treturn -1;\n+\n+\tif (connect(s, (struct sockaddr *)&sun, sizeof(sun)) < 0) {\n+\t\tclose(s);\n+\t\treturn -1;\n+\t}\n+\treturn s;\n+}\n+#endif\n+\n /* initialize logging */\n void\n eal_log_init(const char *id __rte_unused)\n@@ -689,8 +806,22 @@ eal_log_init(const char *id __rte_unused)\n \tif (rte_logs.file != NULL)\n \t\treturn;\n \n-\tif (rte_logs.time_format != EAL_LOG_TIMESTAMP_NONE)\n+#ifdef RTE_EXEC_ENV_LINUX\n+\tif (using_journal()) {\n+\t\tint jfd = open_journal();\n+\n+\t\tif (jfd < 0) {\n+\t\t\tRTE_LOG_LINE(NOTICE, EAL, \"Cannot connect to journal\");\n+\t\t} else {\n+\t\t\trte_logs.journal_fd = jfd;\n+\t\t\trte_logs.print_func = journal_print;\n+\t\t\tjournal_send_id(jfd, id);\n+\t\t}\n+\t} else\n+#endif\n+\tif (rte_logs.time_format != EAL_LOG_TIMESTAMP_NONE) {\n \t\trte_logs.print_func = log_print_with_timestamp;\n+\t}\n \n #if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG\n \tRTE_LOG(NOTICE, EAL,\n",
    "prefixes": [
        "v11",
        "8/9"
    ]
}