By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,731 Members | 1,123 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,731 IT Pros & Developers. It's quick & easy.

Modifying cout to display custom text at start

P: 4

I'm working on, to write the debug statements to logfile or console depends on working environment.

What I have did:

Expand|Select|Wrap|Line Numbers
  2.     streambuf *psbuf;
  3.     ofstream logFile;
  6.     psbuf = logFile.rdbuf();
  7.     cout.rdbuf(psbuf);
this cause cout to redirect the output to log and it's working fine.

The situation is, I like to include the date/time, in front of each message.

e.g cout<<"Hello"<<endl;

will log -

[10/10/2010 12:24:32] Hello

Hope I'm clear in my question.

Many Thanks
Oct 12 '10 #1
Share this Question
Share on Google+
1 Reply

P: 4
do any one have any suggestion here?
Oct 15 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.