Message ID | CAODUAvuWUSy3vRzFYSiVbq19Grwj57a3ZWpmERn8DTSXc4-+Pw@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=qxSOnCEQ; 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=mvNCH8X4; 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 4P0rxC3CLhz23gd for <incoming@patchwork.ozlabs.org>; Tue, 24 Jan 2023 00:46:38 +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: In-Reply-To:References:MIME-Version:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=mkSgrudjU/k/5HXCyc5jvfeKKxgYCK5H5JF0nqBsMNk=; b=qxSOnCEQbUNudZHLRkT6Wy1Y9z 7CcDwY0Llz1SnZ1WBg1unxlvzUD3MakWy2TO/NSEYQz/N6aR1Lj6JWDXdaim2cM3eljPMsm4DYFwU j73d7OzxP0q9Bx0MVos8SSFnjK+s3k5MRaDeJZbI7fQhPYphbtcQ5uy9R+4EAwR79DyB7T0gnmH8M MPWcVAfRaKQawNs/kwucn3ZGhoGrMD/Xof2lryoOfCw6B23SecjRwqyK265xHVvMhYra1FY9szczU XdfIgMSvrPSohDhskAa6Yvkt8jHCM0OVD5XwybHon9BtFGzg1+9pCsqmUtVSU3KomQJem4NuU88Od INh4bKEQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pJx6t-00HOgg-2S; Mon, 23 Jan 2023 13:43:43 +0000 Received: from mail-qv1-xf33.google.com ([2607:f8b0:4864:20::f33]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pJx6p-00HOgE-Lt for openwrt-devel@lists.openwrt.org; Mon, 23 Jan 2023 13:43:41 +0000 Received: by mail-qv1-xf33.google.com with SMTP id k12so9088675qvj.5 for <openwrt-devel@lists.openwrt.org>; Mon, 23 Jan 2023 05:43:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=4V4mAG3sNkCOzNJSxgPCgdLlob6u9glvmjrzbZX2YAc=; b=mvNCH8X4V2hiHce5QLZhbWwSYX4uti7ReTOWV7rene/8PfAVxqSNDvR4kI8w4+gfY/ 2Ws3NAYgTbkandGSegExl6fUTfJJVC9DcB86yLFxhfLmyQHOqMmSmZ6jQyBzf0Hntieg L/EeKIXaifIk9naNlga9LCOrF8/YXcha4Q3DHTqMLjWuQOKjG3CLj+mrYwmktao8k0yM kq816n6gIez4s58fVekRP4556VnSuGsVe16eVnpdZ+FZ5Znj2m7/go07zcC1PCQNPUQ8 qwQeqzqT2HdBOlYYCYl8VT/UDOSi9/DNE/RYufGHmrS6uNexSM4yj6GQeKzBsokMGpmW zEcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=4V4mAG3sNkCOzNJSxgPCgdLlob6u9glvmjrzbZX2YAc=; b=1iDJF62UhUpGi2mZgFyJEugSukID7ZadCd9xOcZ2k4JzhIgtwKZKHk8vGb+6gIcj+1 Xk1N13UxsGyxiDOlThXTt7Q/cidwS4kQQ6nQk1BXO1p/ErlA+jmhSLlCsLVKEsDRo3Fe gMAptabUsGdJdNzZ4DBD1GT0PvgE5yMSpngs5PZQ1fRtAgiQzaJngbmIqiwV6Tv64n5v tTx7Rc14MRYbgGLrbAS85KtYtvMQ2B6jqbDVu/1Y+FKE5O9ZwkXDol5AycK1r4wykz7Y PECS9KgKZUncYq/BrfIPgTsn7y5qFQP77nGFGZi7EgJYFpk9adelva1QoYFLNPr46iZN SNyg== X-Gm-Message-State: AFqh2kof2u3cW8nxFMcFD1jKpWNz6veMEX7TCI35DT/VYVyNzb7n/KMG sMx9rsxITRmMhJlA5HepBpcSnApAWy5+cFVuUJMCMW07BodIMw== X-Google-Smtp-Source: AMrXdXs6Knc0dAkfPWmgN0uk4An5biWIKduHZZzepGLt2cU0EIz1lta8410XwyAZASBy5Nhlgebf46mCE9cbINL9KHQ= X-Received: by 2002:ad4:530e:0:b0:535:276:9240 with SMTP id y14-20020ad4530e000000b0053502769240mr1293455qvr.37.1674481412813; Mon, 23 Jan 2023 05:43:32 -0800 (PST) MIME-Version: 1.0 References: <CAODUAvs5+5PX6OtD9BbcsNNmi8Baogx1EFeO7fRuiJdbz6+_Wg@mail.gmail.com> In-Reply-To: <CAODUAvs5+5PX6OtD9BbcsNNmi8Baogx1EFeO7fRuiJdbz6+_Wg@mail.gmail.com> From: Dan Brown <danbrown@gmail.com> Date: Mon, 23 Jan 2023 14:43:21 +0100 Message-ID: <CAODUAvuWUSy3vRzFYSiVbq19Grwj57a3ZWpmERn8DTSXc4-+Pw@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_054339_777062_5335E664 X-CRM114-Status: GOOD ( 13.37 ) 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:f33 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 14:28:40.199440398 +0100 @@ -60,8 +60,9 @@ 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 regex_t regexp_preg_include, regexp_preg_exclude; +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 --- Update: this newer version fixes a bug where the -e and -E options would be mutually exclusive instead of independent. Sorry. 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,8 +158,11 @@ static int log_notify(struct blob_attr * return 0; m = blobmsg_get_string(tb[LOG_MSG]); - if (regexp_pattern && - regexec(®exp_preg, m, 0, NULL, 0) == REG_NOMATCH) + if (regexp_pattern_include && + regexec(®exp_preg_include, m, 0, NULL, 0) == REG_NOMATCH) + return 0; + if (regexp_pattern_exclude && + regexec(®exp_preg_exclude, m, 0, NULL, 0) != REG_NOMATCH) return 0; t = blobmsg_get_u64(tb[LOG_TIME]) / 1000; if (log_timestamp) { @@ -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; @@ -361,8 +366,13 @@ int main(int argc, char **argv) hostname = optarg; break; case 'e': - if (!regcomp(®exp_preg, optarg, REG_NOSUB)) { - regexp_pattern = optarg; + if (!regcomp(®exp_preg_include, optarg, REG_NOSUB)) { + regexp_pattern_include = optarg; + } + break; + case 'E': + if (!regcomp(®exp_preg_exclude, optarg, REG_NOSUB)) { + regexp_pattern_exclude = optarg; } break; case 't':