Modifying cout to display custom text at start

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Gurinderc
    New Member
    • Sep 2010
    • 4

    Modifying cout to display custom text at start

    Hello,

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

    What I have did:

    Code:
    	
    	streambuf *psbuf;
    	ofstream logFile;
    	logFile.open(LOGFILE);
    
    	psbuf = logFile.rdbuf();
    	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
  • Gurinderc
    New Member
    • Sep 2010
    • 4

    #2
    do any one have any suggestion here?

    Comment

    Working...