J
Jens Thoms Toerring
Hi,
I haven't programmed in C++ for some time and now coming back to
it I seem to have my "senior moments". I would like to write a kind
of logger with a twist in that the file name to use for logging will
only be known after a configuration file has been read in. Of course,
I also would like to log problems encountered while reading that con-
figuration file. So my idea was to store the stuff send to the logger
while the file name isn't yet known to a stringstream and, once the
log files name is available, write the accumulated string to that
file and switch to writing to the file for the rest of the time the
program runs.
I would, of course, like the logger to be an object one can use
the '<<' operator on, so my first idea was to derive it from
std:stream. But is that still an "is-a" relationship, i.e. a
specialization of stdstream or is it something that goes be-
yond that? I'm at a loss if this can be done and if possible, how.
Has someone perhaps a few helpful hints or pointers - or maybe can
tell me that this is just a crap idea and I should stop waisting
my time worrying about it?
Thanks and best regards, Jens
I haven't programmed in C++ for some time and now coming back to
it I seem to have my "senior moments". I would like to write a kind
of logger with a twist in that the file name to use for logging will
only be known after a configuration file has been read in. Of course,
I also would like to log problems encountered while reading that con-
figuration file. So my idea was to store the stuff send to the logger
while the file name isn't yet known to a stringstream and, once the
log files name is available, write the accumulated string to that
file and switch to writing to the file for the rest of the time the
program runs.
I would, of course, like the logger to be an object one can use
the '<<' operator on, so my first idea was to derive it from
std:stream. But is that still an "is-a" relationship, i.e. a
specialization of stdstream or is it something that goes be-
yond that? I'm at a loss if this can be done and if possible, how.
Has someone perhaps a few helpful hints or pointers - or maybe can
tell me that this is just a crap idea and I should stop waisting
my time worrying about it?
Thanks and best regards, Jens