From patchwork Tue Jul 11 15:55:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ron Brash X-Patchwork-Id: 786660 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 3x6RWz6Xtlz9s7g for ; Wed, 12 Jul 2017 01:56:15 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="FmY34OfX"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="tvQXh7Cq"; 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=t3RnmRdGny8o6CQcMhpi3bBlfnym6HMAKSw95Jw6wGc=; b=FmY 34OfXZDSnGAxxjmmR2xW/tsVuqDfQhg29/frEl/IjWVu1qA6egyGvh6nfoZmh9QjHdLcnZ21oRXvE sHDwXxb0MTbmwfxSsyxQjbLMgd+Ah11qq+mx4TtP0sO04ccRR+29CaV6405qRZ2Zqcd6xOP6nrAfl HVE7F0sph7OyyjgoaOjvX7NgT/HkS6eU6dnF4jJxoR2ko04eGNMDXREItWIF8HdZrN68I8DDeOgAw PuBiPk7FBolt1nxAPnJNN6esrGDCXkJtyLjYGnhpl/K37MVhZxvX4lv5R0pnHyL8LgXgaF/p36bqD MRYN8gTG1ckID0xZ7eRN7Hf+1BYZVUA==; 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 1dUxWC-0004nI-T9; Tue, 11 Jul 2017 15:56:08 +0000 Received: from mail-qk0-x235.google.com ([2607:f8b0:400d:c09::235]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dUxWA-0004mg-0Q for lede-dev@lists.infradead.org; Tue, 11 Jul 2017 15:56:07 +0000 Received: by mail-qk0-x235.google.com with SMTP id p21so5927911qke.3 for ; Tue, 11 Jul 2017 08:55:49 -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=R3CAwpLvuIIDlMrfE4xEEIonHOkcQ1X0BfJxnYp9tPg=; b=tvQXh7Cqueox3J+dqJr3LTUbMy+hrb2cw7TZnn1IFDFvO4xjLHiYPb57PSWOuv4KFT 1vaP2tyvwpkdS3FzzDl+DBYJTjnbFN2eCjbwQUM+Mm9HVINzy/xSo4dIUIj7M/ouKw3d +nwYWOBlIl+geApcxKpPRl/7/pHSzeEkaQVQN4SRmw+74NMjs3zJ7m3xCULhKE8S9ypd mQTU785I+y3+8p2dDiCm1wwy+GYsH5xo8e2ML/X5Hez2b2NAjPbXVDSFQms6R04HNjph OUYpHj//FEr/zWWkmv8u4r+b0zc72G+KFeC44UJrU4Zys+8PdknZ9ILCXcCDELKasjs8 sZCg== 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=R3CAwpLvuIIDlMrfE4xEEIonHOkcQ1X0BfJxnYp9tPg=; b=n9ktd3mPuD99f6ovHbgCyW4PTsP0Q6X3e7n9CSuKnX0rDx3S4JnUpJnkBVjmB2Ec65 FUaUK9fgwlq/xC+/jHBcnN9szjqPvchhrPOmpOxyff9IbqXLRsPEApD8BXcLnfsm1Iug WQASYKERXJYGhanOiIyYIjc9ouOCVDEgPG6aISozfA8MGGuLxpqqoB3ALdf9xf2v9mQz Plhi0y1S8C6qTz+sG4HLlWInCabcgBsLD3zZ0ZXsnyyUEt/1sxFCvWc/NfrM5p8fMUBN FqKGfvcy5LJa1trZ+vmL54LQILo41v3V/7qlEAyr8KzT1jkx1ZV3sIpg0O+xl+uScloM dYFQ== X-Gm-Message-State: AIVw113IB3e4lFOHkauJpUC9dGNlTtQRHADFD/MlO6/7uT+BVNm+0MgY ukAMzJL3ClO6/FlKSzupeGRd0T1ENnEG X-Received: by 10.55.153.129 with SMTP id b123mr534956qke.162.1499788548041; Tue, 11 Jul 2017 08:55:48 -0700 (PDT) MIME-Version: 1.0 Received: by 10.237.56.130 with HTTP; Tue, 11 Jul 2017 08:55:47 -0700 (PDT) From: Ron Brash Date: Tue, 11 Jul 2017 11:55:47 -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-20170711_085606_188994_9FBC7E22 X-CRM114-Status: UNSURE ( 8.63 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2607:f8b0:400d:c09:0:0:0:235 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 log priority filtering to daemon 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 After wanting to filter logs at the logger level, instead of post log-write, we added a feature such that we can filter within the logd daemon itself. Signed-off-by: “Ron Brash <“ron.brash@gmail.com”> --- log/logd.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/log/logd.c b/log/logd.c index 07aee2b..5b99fdf 100644 --- a/log/logd.c +++ b/log/logd.c @@ -27,6 +27,7 @@ #include "syslog.h" int debug = 0; +int priority = 0; 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; + } 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; + } + break; } } log_size *= 1024;