﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	difficulty
702	macro expansion time category specification filter for log5scm	Moritz Heidkamp	certainty	"The attached patch adds support for defining a category specification that's matched against at macro expansion time. If it matches, the {{{log-for}}} macro will expand to {{{(void)}}} and thus not generate any runtime overhead. The specification is passed through the environment variable {{{LOG5SCM_CAT_SPEC}}}. To implement this feature it was necessary to split the log5scm module into two modules (log5scm-lolevel and log5scm) so that the category spec matching code can be used both at macro expansion and run time.

For example, consider this program:

{{{
(use posix log5scm)

(define-category foo)
(define-category bar)

(start-sender main 
              (port-sender (current-output-port))
              (category bar))

(log-for (foo) (begin (sleep 2) ""some expensive foo bar""))
(log-for (bar) ""some bar"")
}}}

Even though we only have a sender that's interested in log messages of the category bar the program will wait for 2 seconds because senders may change at runtime. The (sleep 2) is contrived of course, imagine building some elaborate data structure for debugging puproses there instead. Now invoking this program with {{{LOG5SCM_CAT_SPEC=bar}}} will completely eliminate the {{{(log-for (foo) ...)}}} call (well, replace it with {{{(void)}}} in fact). This can be useful for stripping debug messages completely from a compiled program by passing something like {{{LOG5SCM_CAT_SPEC='(not debug)'}}}."	enhancement	closed	not urgent at all		extensions	4.7.x	fixed	log5scm		
