In writing a logger for an application, the datestamp ends up adding a new line.
The datestamp function is as follows:
string log_class::get_time() {
time_t rawtime;
time (&rawtime);
string timestamp;
timestamp = (ctime (&rawtime));
return timestamp;
}
This outputs something like Tue Sep 6 14:58:35 2011
, but when called in the main function with logfile << get_time() << " " << logmessage_to_write << endl;
, it produces a newline after the datestamp like:
Tue Sep 6 14:58:35 2011
data goes here
I would like it to be on one line, as in Tue Sep 6 14:58:35 2011 data goes here
, but I can't figure out how to do this. If anyone has an idea how to remove the newline, that would be great.