From patchwork Wed Jul 5 15:01:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ron Brash X-Patchwork-Id: 784668 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3x2kcH0dZwz9s0Z for ; Thu, 6 Jul 2017 01:02:07 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="o3o60aw4"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="g+rRYy37"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:To: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=9jfTCxSAqnC1naAM2U2UuBoGJ1dFgJPyYDwzrGFEuCI=; b=o3o 60aw4d/+HFDfwdYtQAo2Edo2QW4M0FtcYwbzrUQOWIyyy8TN68EqgX7cWu1wfYBNvOvZVbwXA+++P obtbecuJ8xNYzFNOmfU/lTvU9WnGKwmfXiKYvGTxom6X89VPRmQ3yT+A19yrH//43NipF6lAp/TN7 0rNRilzQeoBm+HvF9Iu0RxJ7OjKx0uxcVpP3hz2i7N9kq3O35RhQzab37380wb/+QkSRvRqbbT6iw Ww7my/BYa8cwxCRmwfOSIMdP0oErU8zf9s0EwbnISiGgzl7v7Yp20cOsKwSnS5Hu8DP7LLxQqwfXq VetbrmGrw18DAuG4BV4F5QAD7L5LZHQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dSloR-0005XZ-55; Wed, 05 Jul 2017 15:01:55 +0000 Received: from mail-qk0-x244.google.com ([2607:f8b0:400d:c09::244]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dSloN-0005VX-Te for lede-dev@lists.infradead.org; Wed, 05 Jul 2017 15:01:53 +0000 Received: by mail-qk0-x244.google.com with SMTP id p21so31605312qke.0 for ; Wed, 05 Jul 2017 08:01:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to :content-transfer-encoding; bh=M5aqQ8YMNT2KAt93gbKaTdUu+9d+HrcTDYC8dbiXxBw=; b=g+rRYy37d9G+VnM9jHCMSH6gcvPUDD+16HIICTpah92Lq7/PAdFuPcKmzyhH3BVzz8 qKhFGl+sr7RSXmT73qiSYAfoceetAIC+nfs6qpqqOw6P8Oq02fyWUuF5KBU0DE+B2X8X aovjTXPHgpFoisK7ePxZQniNoCN0MEmS+lVSll4jr7ULrbDMmKw1m9V859Q/aKRZKeo2 zhLLqESjqfuW8PA0z9NvBz+ede/18cyrkWeZABkVfDV3sI4MnvJkGjAGef0oxkYCbWRJ 2JR5rjPH9n3Bvyl4FxiF4eCcVdJdiXGL6JPQVZV+bXtUV+uxrzrch/mjodnVTC8Gn3m4 VDfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to :content-transfer-encoding; bh=M5aqQ8YMNT2KAt93gbKaTdUu+9d+HrcTDYC8dbiXxBw=; b=T3UlQIK8d2p/CQCFMEkIYvUjk7wjT/2c69qmX2E3fW+Lm0jXK163nXhfrLLmP/GTOD USsr9pKZmCl0PIlUjqmTojnUUw6Udc9qYTODL5sIpn13XhEZNcx+LjtsaST+swjM8+ut euiS/yR21lqM0dMjPNi7llGQVFhXSMGDrZNl6F1XdGoH4yFdmZcvkr/QUxjcOumjewGA RfaEpVG+twc6+bb3iOcOOo+cZSLuH6i4tnNHm2T6W0aVSM+dWK+pwJ8avxB+FH3GD4Do SzHPBF4Nm7lunLSAKY9Ruv2PM8uFuLNYtyIgyaMZTyXVzqZmuSE6rjJij8ojTIDcaTfp fxYw== X-Gm-Message-State: AKS2vOzZ9jZT1U7rP/fLD51vTfl8KKvM4C3S8h0ac0gKow4mRodEgOpF EtFRVjXUGB85Xa/qwqIOUXzYyTA6HKlC7Fw= X-Received: by 10.55.170.212 with SMTP id t203mr49933935qke.200.1499266890169; Wed, 05 Jul 2017 08:01:30 -0700 (PDT) MIME-Version: 1.0 Received: by 10.237.56.130 with HTTP; Wed, 5 Jul 2017 08:01:29 -0700 (PDT) From: Ron Brash Date: Wed, 5 Jul 2017 11:01:29 -0400 Message-ID: To: lede-dev@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170705_080152_168532_7DAA5614 X-CRM114-Status: GOOD ( 10.23 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2607:f8b0:400d:c09:0:0:0:244 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (ron.brash[at]gmail.com) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -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_AU Message has a valid DKIM or DK signature from author's domain Subject: [LEDE-DEV] [PATCH ubox] Add logd priority filtering option X-BeenThere: lede-dev@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Lede-dev" Errors-To: lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Hello all, Here is a repost of the previous patch split into a single one. This patch adds the logger priority filtering needed by one of our clients. For example, they who remain unnamed, are running a really stripped down system that wants to parse logs at the logger level. They have some code to present logs to a user, but they want to minimise the logging "below" and opted to use the unused field connloglevel. Ron diff --git a/log/logd.c b/log/logd.c index 07aee2b..a60cb8f 100644 --- a/log/logd.c +++ b/log/logd.c @@ -27,6 +27,7 @@ #include "syslog.h" int debug = 0; +int priority = 7; static struct blob_buf b; static struct ubus_auto_conn conn; static LIST_HEAD(clients); @@ -182,6 +183,9 @@ ubus_notify_log(struct log_head *l) if (list_empty(&clients)) return; + if((l->priority & 7) > priority) { + return; // skip if greater (logger level filtering) + } blob_buf_init(&b, 0); blobmsg_add_string(&b, "msg", l->data); blobmsg_add_u32(&b, "id", l->id); @@ -214,13 +218,21 @@ main(int argc, char **argv) int ch, log_size = 16; signal(SIGPIPE, SIG_IGN); - while ((ch = getopt(argc, argv, "S:")) != -1) { + while ((ch = getopt(argc, argv, "P:S:")) != -1) { switch (ch) { case 'S': log_size = atoi(optarg); if (log_size < 1) log_size = 16; break; + case 'P': + priority = atoi(optarg); + if (priority < 0) + priority = 0; + else if(priority > 7) { + priority = 7; // bounds check + } + break; } } log_size *= 1024;