G
grahamo
Hi,
I have written an app that uses streams in a very standard way. I make
use of some legacy code something like this;
// legacy operator<< , standard enough.
ostream& legacy_function:perator<<(args);
cout << legacy_function(args) << endl;
legacy_function(args) simply takes the args and does some fancy
parsing etc and returns a ostream object in the usual manner. With
this code in dev, I get all my info on stdout, no problemo.
However, now that I have everything up and running I have to log to a
file instead of stdout, which was ok for development and debugging
purposes.
I am obliged to use another 3rd party api (again!) which takes the
form;
void log_message(const char*);
This will automatially log my char* to a pre-configured logfile.
However I am not sure how I can get from the ostream returned from
ostream& legacy_function:perator<<(args);
to the char* that I need to pass to log_message(const char*).
Do I simply create an instance (something like)
std:stream output(legacy_function:perator<<(args));
const char* the_char_star_im_after(output.some_method);
I hope I've explained that correctly. I haven't used streams much
(well apart from the obvious use, so forgive me if this is blindingly
obvious).
thanks a million
GrahamO
I have written an app that uses streams in a very standard way. I make
use of some legacy code something like this;
// legacy operator<< , standard enough.
ostream& legacy_function:perator<<(args);
cout << legacy_function(args) << endl;
legacy_function(args) simply takes the args and does some fancy
parsing etc and returns a ostream object in the usual manner. With
this code in dev, I get all my info on stdout, no problemo.
However, now that I have everything up and running I have to log to a
file instead of stdout, which was ok for development and debugging
purposes.
I am obliged to use another 3rd party api (again!) which takes the
form;
void log_message(const char*);
This will automatially log my char* to a pre-configured logfile.
However I am not sure how I can get from the ostream returned from
ostream& legacy_function:perator<<(args);
to the char* that I need to pass to log_message(const char*).
Do I simply create an instance (something like)
std:stream output(legacy_function:perator<<(args));
const char* the_char_star_im_after(output.some_method);
I hope I've explained that correctly. I haven't used streams much
(well apart from the obvious use, so forgive me if this is blindingly
obvious).
thanks a million
GrahamO