473,394 Members | 1,778 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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:

Expand|Select|Wrap|Line Numbers
  1.  
  2.     streambuf *psbuf;
  3.     ofstream logFile;
  4.     logFile.open(LOGFILE);
  5.  
  6.     psbuf = logFile.rdbuf();
  7.     cout.rdbuf(psbuf);
  8.  
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
1 1495
do any one have any suggestion here?
Oct 15 '10 #2

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

Similar topics

1
by: David Thomas | last post by:
Hi there, a while ago, I posted a question regarding reading japanese text from a text file. Well, since I solved the problem, I thought I'd post my solution for the benefit of other people with...
1
by: Gema Gema | last post by:
I have a large collection of directories full of various files and am looking to create custom text files for the contents of each directory. Here is the situation: The directories are named...
4
by: hoke | last post by:
I want to display plain text files in the browser. The files contain html and javascript and have a .txt extension. This works fine with files with just html. Unfortunately when showing files with...
3
by: Nick Haines | last post by:
I need to write my own custom text edit control.. but I'm not sure where to start - I've never written a custom control... the features I want are somewhat similar to the VS .Net text editor - text...
4
by: Tigrou | last post by:
Hello, In a Oracle Database i have text who are stored, this text are in RTF format, you can see an example below: {\rtf1\ansi\ansicpg1252\deff0\deflang1036{\fonttbl{\f0\froman\fcharset0...
0
by: Terp | last post by:
Hello all, Here is what I need to do: I need a custom text control of some sort that has the following characteristics: 1. Displays plain text. 2. Never shows scrollbars. 3. Only displays...
3
by: Mike L | last post by:
Custom text box to go to next text box in tab list. When the user types in a text box and the max length is meet, the focus goes to the next text box in the tab list. Here is my code so far, but...
3
by: jiayanxiang | last post by:
Is there any sample code to use Javascript to load and display a text file? It will be best if the user can select files using some kind of explorer. If that's complex, a text box to specify the...
1
by: =?Utf-8?B?bWFuanUxMjM0?= | last post by:
Hi, I need to write a code where if the user selects a radio button depending on that i need to display the text. can any one tell me how i can do this ? Thanks in adavnce
2
by: kimiraikkonen | last post by:
Hi experts, I need to display some custom text ouptut in a Listbox and the first 4 lines of listbox (index items) will be removed. the problem is not to know how to display custom text "line by...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.