comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Suppressing diagnostic messages en masse
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Suppressing diagnostic messages en masse [message #47323] Thu, 02 February 2006 16:45 Go to next message
MarioIncandenza is currently offline  MarioIncandenza
Messages: 231
Registered: February 2005
Senior Member
Hey great minds,

I am engaged in semi-permanent debugging of some pretty long scripts,
which in the course of developing I have peppered with PRINT statements
to achieve various diagnostic ends.

I don't think the script is "final," whatever that means, but it's time
to do some production runs, where the script will be invoked 10,000
times, instead of the usual 1.

I can do a search-and-replace to comment out the diagnostics for this
purpose, but what would really be nice is if I could somehow put a
keyword flag into the routine that, when set, would suppress|promote
the diagnostic messages. Sounds like the sort of thing that might
exist. Anyone know how to do this?
Re: Suppressing diagnostic messages en masse [message #47393 is a reply to message #47323] Sun, 05 February 2006 11:09 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
"Ed Hyer" <ejhyer@gmail.com> writes:
> Hey great minds,
>
> I am engaged in semi-permanent debugging of some pretty long scripts,
> which in the course of developing I have peppered with PRINT statements
> to achieve various diagnostic ends.
>
> I don't think the script is "final," whatever that means, but it's time
> to do some production runs, where the script will be invoked 10,000
> times, instead of the usual 1.
>
> I can do a search-and-replace to comment out the diagnostics for this
> purpose, but what would really be nice is if I could somehow put a
> keyword flag into the routine that, when set, would suppress|promote
> the diagnostic messages. Sounds like the sort of thing that might
> exist. Anyone know how to do this?

I have had a need for this before. There are a lot of cases where I
need to keep a log of diagnostic output, but not print it unless there
is an error, or to save it to a file at the end.

I developed a small routine called PRINTLOG which is a drop-in
replacement for PRINT. You work it like this,
PRINTLOG, LOG=LOG, "X = ", X
PRINTLOG, LOG=LOG, "Y = ", Y
and the result is that the LOG variable slowly builds up a transcript
of whatever you print to it. Unfortunately you will need to retool
your subroutines to accept a LOG keyword, but once you do that, you
can maintain one continuous log while traversing up and down the
subroutine call tree. Like this,
MYPROC1, LOG=LOG, X, Y, Z
... within MYPROC1 ...
PRINTLOG, LOG=LOG, "X = ", X
MYPROC2, LOG=LOG, L, B
... within MYPROC2 ...
PRINTLOG, LOG=LOG, "L = ", L
PRINTLOG, LOG=LOG, "B = ", B

The final trick is that you can globally turn the console output on or
off by setting,
PRINTLOG, DEFAULT_PRINT=0
and later re-enable it with
PRINTLOG, DEFAULT_PRINT=1

Hope that helps!
Craig

See the following web page for PRINTLOG,
http://cow.physics.wisc.edu/~craigm/idl/


--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@REMOVEcow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Array slices
Next Topic: Lotto Winner Looking for Work

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 12:49:34 PDT 2025

Total time taken to generate the page: 1.03932 seconds