From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: buffer2.nntp.dca1.giganews.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Brian Drummond Newsgroups: comp.lang.ada Subject: Re: Running a preprocessor from GPS? Date: Wed, 29 Jul 2015 10:29:50 +0000 (UTC) Organization: A noiseless patient Spider Message-ID: References: <9d870b85-cd15-4814-af8d-0e0cd65eaff6@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Wed, 29 Jul 2015 10:29:50 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="da745e888d4a5182b5fda6212bbb0a63"; logging-data="22487"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18wmGDmLD1BRilwqVj22MtCUnXDCNlxdts=" User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2) Cancel-Lock: sha1:v2XDdmL4G/LtuPIjXuQv4iUD48U= Xref: number.nntp.giganews.com comp.lang.ada:194429 Date: 2015-07-29T10:29:50+00:00 List-Id: On Tue, 28 Jul 2015 04:39:45 -0700, EGarrulo wrote: > On Tuesday, July 28, 2015 at 12:30:18 PM UTC+2, Brian Drummond wrote: >> Wrap the test and the string formatting into a procedure. You'll >> probably need a family of such procedures for different formats - keep >> them in a package. >> >> Write a second package body, where every procedure implementation is >> simply "null;" and build with whichever package body is appropriate. > > Thanks but this wouldn't work in my case because I want logging code to > stay, while being able to enable or disable it -- and with different > levels -- at runtime. waitaminit ... if you use a preprocessor, the logging code DOESN'T stay and isn't controllable at runtime. I think you misunderstood, maybe I need to be more verbose... By "Wrap the test and the string formatting into a procedure." I meant ----------------------------------------- procedure Trace_If_Active(Me: Some_Type; Message : String; Data : Natural; Message2 : String := "") is begin if Active (Me) then Trace (Me, Message & Natural'Image(Data) & Message2); end if; end Trace_If_Active; ----------------------------------------- which allows runtime control through the value of Me. This ensures the string formatting is conditional on the test. The drawback is that you need an ad-hoc set of these procedures for different output formats, though default arguments for "Message2" keep the noise down a bit. Because they are relegated to a package they don't add clutter to the codebase (and may be re-usable across projects). The second (null) package body, selected at build time, simply replaces the preprocessing, I never intended it to replace the runtime control aspects. -- Brian