Topic: I need a smart logger object...
Author: susan.dugas@gtri.gatech.edu (Susan Dugas)
Date: 1995/07/10 Raw View
----------------------------------------
I'm posting this for my husband because he seems to be having problems
posting from his newsreader. So if you are going to send email, I'd
appreciate it if you would send it to him (although I will forward
anything that I may receive).
----------------------------------------
OK, here's a good one...
I'd like to create a message logger class for my programs that looks and
works like an ostream but with a few changes...
let's say I do this:
Logger messageLog;
void foo( int a ) {
messageLog << " a = " << a << endl;
...
}
main () {
foo( 123 );
}
if DEBUG is defined I'd like to see:
<date> <progname> : a = 123
and if DEBUG is not define I'd like to see nothing.
The first thing I have come up with is to derive my own class from
the ostream but then I'd have to redefine the << operator for each
data type. (no fun) I could send the output to /dev/null if DEBUG
is not set but that still takes processor time. I'd like the
statements to endup no-ops if DEBUG is not set.
For now..., I'm using messageLog( "message goes here" ) but this is
restrictive as I am not able to include the values of variables in
the messages (inless I write a printf() style vararg method)
Anybody got any good ideas? Suggestions are greatly appreciated.
--
Paul Dugas
TRW Inc., Suite 480 email: paul_dugas@rc.trw.com
4751 Best Road voice: 404.766.7699 x226
Atlanta, Ga. 30337 fax: 404.766.7595