Message ID | CAODUAvs5+5PX6OtD9BbcsNNmi8Baogx1EFeO7fRuiJdbz6+_Wg@mail.gmail.com |
---|---|
State | Superseded |
Headers | show
Return-Path: <openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org> X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=<UNKNOWN>) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=CBJCCMLs; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=npr0iM2H; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4P0qw06zMnz23gd for <incoming@patchwork.ozlabs.org>; Tue, 24 Jan 2023 00:00:32 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From: MIME-Version:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=zAdu4l92+hFmj3daxj5bG6Uh7HtAmt82HZQA+nhQpkI=; b=CBJ CCMLsSgjCSwvB6cNDFDaJ67f7VlJCtR0ZfIYwq5AN/N2tCk/EiTxAyXmHGrWJmw9LcDWSCEL3xQdd +dmOgrHaJVWkEukqmvCHOQ5QDZkiMGCwFIqi2G5lonjsvmTI6uVSSBzphaNOLziduqaBYE9uYNZmz ATbM/6n/BlUzTxPGOX2ug84rchPqMWFOGC4oroeozf1JKuE4yLekqI4vRG0d47hxmNxejvUmz1ckX BQRkjpVtWh05yElqTrcU7JPa9YeZYLSChpCNBx9ekTmF0KEipAMTBd3Bv386nSEQO19WRYmV4aJRd 31HwItldXWWiLWGiC3+IsJV1VWMPSQQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pJwOw-00HHZn-1Y; Mon, 23 Jan 2023 12:58:18 +0000 Received: from mail-qv1-xf2b.google.com ([2607:f8b0:4864:20::f2b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pJwOo-00HHWM-LQ for openwrt-devel@lists.openwrt.org; Mon, 23 Jan 2023 12:58:13 +0000 Received: by mail-qv1-xf2b.google.com with SMTP id n2so9012401qvo.1 for <openwrt-devel@lists.openwrt.org>; Mon, 23 Jan 2023 04:58:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=5BgIlDr+V/6NDJJYORcZQ0LX9Ky4jbh94fp/9lsuZjs=; b=npr0iM2H4h75mvBBvHpca99KhwkbdWX7BprdzpKhHXCwWb3EllFfcx9jAQwhN6IJMQ 6Pv8ZF7AgRLmb4sNdw8SfZpGiKdjxc49LvjQAl9eY5VU0LwoY3i15GQLLLi+7thIN1E7 ZhnixFRAdQQDW+8wcHwEXJuXxK7AMg09Q7aMcyk9ijV1N7+Xe080udXAW9StWwqsGbxr XHbUEd3hSWxU4d3nX2nMhyrn46EIQHsoV69aMaajwx0+XqzGdX+63eTMYhgsqXrmsO7o FxdopWDSPCfZISmJHn+xAhzBynwFSPcxyKN2AjZiYZfDc7znzsVHvpFlDoi2Xco64YAn hf6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=5BgIlDr+V/6NDJJYORcZQ0LX9Ky4jbh94fp/9lsuZjs=; b=oZjAflQGrIG+rz9s4u8Rko4Z49eEu9o/LxD6dBbLq5XBQ+xb+SrzrgqfDTauuMc6m4 ZFuLFyJtvnFDc31y64eoeygMSjyoYBU1Aug6ox0ts3Vffk5GJevvURMXR5J7IkUEajjo acfKGW2+ly5FDsur6Ok80hugSzrQQj0Y/h5WKpEfo3teS3UbTPhS3kTjPfdUI/JftaW2 qe9MHySvuh/t1sci+mG4n+AhjV97WSdQ96LWRE53yjUJ644XQrhjgiTigmLivwgo54TU MsoaswpX5b3bEFI+t7Am+8lBV7MGJ19+lEvsEMnr4h7cqCUrE60qeX+TvR8v1x9jFU/G x8BQ== X-Gm-Message-State: AFqh2koDRKKWGQ14e1jLywRMrcscrLW0UiKYqN4saqa7f67Ydqoz8xPX Zjf0Wo1gun25FtbIt9qzYUk2IhU2Hf/iHC4rA321ikOxpZrDDg== X-Google-Smtp-Source: AMrXdXu1J/nMRMaiStmyNGfWb1aK7T5fkEqq+1uob/qVmZI3ITyQ2wX4zN6hp8q3wSqxIDcHwd+6ubx5BZ4C3fFh7fc= X-Received: by 2002:a0c:8030:0:b0:532:277b:dfb with SMTP id 45-20020a0c8030000000b00532277b0dfbmr1080558qva.97.1674478687043; Mon, 23 Jan 2023 04:58:07 -0800 (PST) MIME-Version: 1.0 From: Dan Brown <danbrown@gmail.com> Date: Mon, 23 Jan 2023 13:57:55 +0100 Message-ID: <CAODUAvs5+5PX6OtD9BbcsNNmi8Baogx1EFeO7fRuiJdbz6+_Wg@mail.gmail.com> Subject: [patch] logread : add option to exclude lines matching regex To: openwrt-devel@lists.openwrt.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230123_045810_771879_DA566B29 X-CRM114-Status: GOOD ( 12.18 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Dan Brown logread: add option to exclude lines matching regex This adds another filtering option (-E) to exclude lines that match a regex, similar to the existing include option (-e): -e <pattern> include messages matching a regexp -E <pattern> exclude messages [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:f2b listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [danbrown[at]gmail.com] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List <openwrt-devel.lists.openwrt.org> List-Unsubscribe: <https://lists.openwrt.org/mailman/options/openwrt-devel>, <mailto:openwrt-devel-request@lists.openwrt.org?subject=unsubscribe> List-Archive: <http://lists.openwrt.org/pipermail/openwrt-devel/> List-Post: <mailto:openwrt-devel@lists.openwrt.org> List-Help: <mailto:openwrt-devel-request@lists.openwrt.org?subject=help> List-Subscribe: <https://lists.openwrt.org/mailman/listinfo/openwrt-devel>, <mailto:openwrt-devel-request@lists.openwrt.org?subject=subscribe> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "openwrt-devel" <openwrt-devel-bounces@lists.openwrt.org> Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org |
Series |
logread : add option to exclude lines matching regex
|
expand
|
--- log/logread.c.orig 2023-01-23 13:16:59.502476137 +0100 +++ log/logread.c 2023-01-23 13:34:27.656416367 +0100 @@ -61,7 +61,8 @@ static const struct blobmsg_policy log_p static struct uloop_timeout retry; static struct uloop_fd sender; static regex_t regexp_preg; -static const char *log_file, *log_ip, *log_port, *log_prefix, *pid_file, *hostname, *regexp_pattern; +static const char *log_file, *log_ip, *log_port, *log_prefix, *pid_file; +static const char *hostname, *regexp_pattern_include, *regexp_pattern_exclude; static int log_type = LOG_STDOUT; static int log_size, log_udp, log_follow, log_trailer_null = 0;
From: Dan Brown <danbrown@gmail.com> logread: add option to exclude lines matching regex This adds another filtering option (-E) to exclude lines that match a regex, similar to the existing include option (-e): -e <pattern> include messages matching a regexp -E <pattern> exclude messages matching a regexp The two options -e and -E are independent, and lines must pass both tests to appear in program output. * 'logread -E dhcp' will display all lines that do not contain the string "dhcp" * 'logread -e dhcp -E 192.168' will display all lines that contain "dhcp" and do not contain "192.168" signed off by: Dan Brown, danbrown@gmail.com --- The motivation for adding this option to logread is to remove frequent and uninteresting loglines from being displayed in Luci. One way to achieve this is to install an alternate logging system (syslog-ng or rsyslog) and set up rules for filtering there. Instead of that, I would prefer to use the simpler and standard logd/ubox method with this small enhancement. This patch applies to the ubox project (https://git.openwrt.org/?p=project/ubox.git;a=summary) static int log_timestamp; @@ -157,9 +158,12 @@ static int log_notify(struct blob_attr * return 0; m = blobmsg_get_string(tb[LOG_MSG]); - if (regexp_pattern && + if (regexp_pattern_include && regexec(®exp_preg, m, 0, NULL, 0) == REG_NOMATCH) return 0; + if (regexp_pattern_exclude && + regexec(®exp_preg, m, 0, NULL, 0) != REG_NOMATCH) + return 0; t = blobmsg_get_u64(tb[LOG_TIME]) / 1000; if (log_timestamp) { t_ms = blobmsg_get_u64(tb[LOG_TIME]) % 1000; @@ -226,7 +230,8 @@ static int usage(const char *prog) "Options:\n" " -s <path> Path to ubus socket\n" " -l <count> Got only the last 'count' messages\n" - " -e <pattern> Filter messages with a regexp\n" + " -e <pattern> include messages matching a regexp\n" + " -E <pattern> exclude messages matching a regexp\n" " -r <server> <port> Stream message to a server\n" " -F <file> Log file\n" " -S <bytes> Log size\n" @@ -313,7 +318,7 @@ int main(int argc, char **argv) signal(SIGPIPE, SIG_IGN); - while ((ch = getopt(argc, argv, "u0fcs:l:z:Z:r:F:p:S:P:h:e:t")) != -1) { + while ((ch = getopt(argc, argv, "u0fcs:l:z:Z:r:F:p:S:P:h:e:E:t")) != -1) { switch (ch) { case 'u': log_udp = 1; @@ -362,7 +367,12 @@ int main(int argc, char **argv) break; case 'e': if (!regcomp(®exp_preg, optarg, REG_NOSUB)) { - regexp_pattern = optarg; + regexp_pattern_include = optarg; + } + break; + case 'E': + if (!regcomp(®exp_preg, optarg, REG_NOSUB)) { + regexp_pattern_exclude = optarg; } break; case 't':