From owner-freebsd-hackers@freebsd.org Sat Dec 9 16:52:12 2017 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1C266E91233 for ; Sat, 9 Dec 2017 16:52:12 +0000 (UTC) (envelope-from eric@metricspace.net) Received: from mail.metricspace.net (mail.metricspace.net [IPv6:2001:470:1f11:617::107]) by mx1.freebsd.org (Postfix) with ESMTP id E41B36C550 for ; Sat, 9 Dec 2017 16:52:11 +0000 (UTC) (envelope-from eric@metricspace.net) Received: from [IPv6:2001:470:1f11:617:3210:b3ff:fe77:ca3f] (unknown [IPv6:2001:470:1f11:617:3210:b3ff:fe77:ca3f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: eric) by mail.metricspace.net (Postfix) with ESMTPSA id 4917C4FEC for ; Sat, 9 Dec 2017 16:52:11 +0000 (UTC) To: "freebsd-hackers@freebsd.org" From: Eric McCorkle Subject: Hopefully useful: macro-controlled logger Message-ID: <0dd5240f-6c70-425f-7e98-7946097ea3ef@metricspace.net> Date: Sat, 9 Dec 2017 11:52:10 -0500 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Dec 2017 16:52:12 -0000 Hi folks, At some point in the past, I recall reading about a log4j-inspired logging API for C that used the preprocessor to avoid introducing runtime overhead. However, I've never been able to find this library, so I've used my own scrappy macro collection over the years. Anyway, on a recent flight I decided to implement a macro-controlled logging API in earnest. The github project can be found here: https://github.com/emc2/mcl It provides the ability to define module-specific loggers, log at different levels, and set a threshold for dynamically-controlled logging levels. Any log message more severe than the dynamic range will be hardwired in place, and any message less severe will be removed at compilation time. It's not large or complicated at all, but hopefully someone will find it useful. If they do, I'd be more than happy to have it added to the FreeBSD base system.