Re: This can't be done in Ada...or?
From: Peter Amey (peter.amey_at_praxis-cs.co.uk)
Date: 02/14/05
- Next message: Marc A. Criley: "Re: Dynamic array allocation and STL equivalents?"
- Previous message: Georg Bauhaus: "Re: This can't be done in Ada...or?"
- In reply to: Per Lindquist: "This can't be done in Ada...or?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 14 Feb 2005 15:21:22 +0000
Per Lindquist wrote:
> Hi, this question has already sort of been discussed in topics about
> multiple target platforms, conditional compilation, preprocessors and
> build strategies. Before giving up I thought I'd give it a try one last
> time...
>
> My impression from reading some threads is that Ada DOES NOT offer a
> decent way to implement trace printouts (log messages), at least not
> with the features stated below.
>
> The problem
> -----------
>
> We want to be able to output log messages, or traces as we call it,
> from an Ada program. There will be a few trace categories like Error,
> Warning, Note etc. The messages (strings) can be sent to a file or
> stdout or whatever (not important).
>
> A call might look something like this:
>
> Trace.Error(Package_Name, Subprogram_Name, "Woops, V=" &
> Some_Type'Image(V));
>
> How do we write a tracing utility in Ada that:
> 1. has different behaviour on different target platforms
> 2. can disable some categories depending on target platform at
> compile-time.
> 3. does *not* cause any execution overhead if disabled.
> 4. does not need yucky "if Trace_Wanted then ... end if;" around all
> calls
> 5. does not need preprocessing (some of you say it's never needed in
> Ada...)
>
> I say it can't be done in Ada. Please prove me wrong!
>
One useful approach I have used is to make us of subunits. Each of the
reporting routines in your package Trace can be made a subunit of Trace.
The subunit itself, e.g. Error, can have two implementations, one
that reports the error and one which is just a null body. The compiler
"make" system and library manager can be used to build different
variants with different levels of reporting. If the stub is marked as
in_line then there is no overhead when the null version is called.
Peter
- Next message: Marc A. Criley: "Re: Dynamic array allocation and STL equivalents?"
- Previous message: Georg Bauhaus: "Re: This can't be done in Ada...or?"
- In reply to: Per Lindquist: "This can't be done in Ada...or?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|