Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Creating a debug stream

Reply
Thread Tools

Creating a debug stream

 
 
ciccio
Guest
Posts: n/a
 
      09-11-2008
Hi,

I would like to write debug output to my screen but I don't want to use
std::cout or std::cerr but rather a thing called debug which would write
to std:cerr. Also I would like to have that each new line would start with
a certain starting character.

An example would then be

debug << "Debug line 1\nDebug line 2" << std::endl;

which should result in the following output to stderr

(D) Debug line 1
(D) Debug line 2

Is this possible?

--
"Yes, it's the right planet, all right, " he said again.
"Right planet, wrong universe. "
 
Reply With Quote
 
 
 
 
Zeppe
Guest
Posts: n/a
 
      09-11-2008
Dear ciccio,

ciccio wrote:
> Hi,
>
> I would like to write debug output to my screen but I don't want to use
> std::cout or std::cerr but rather a thing called debug which would write
> to std:cerr. Also I would like to have that each new line would start
> with a certain starting character.


You can google "c++ log library". A good one seems to be pantheios
(http://pantheios.sourceforge.net/) but yo may just require something
simpler.

Best wishes,

Zeppe
 
Reply With Quote
 
 
 
 
James Kanze
Guest
Posts: n/a
 
      09-11-2008
On Sep 11, 7:01 pm, ciccio <(E-Mail Removed)> wrote:
> I would like to write debug output to my screen but I don't
> want to use std::cout or std::cerr but rather a thing called
> debug which would write to std:cerr. Also I would like to have
> that each new line would start with a certain starting
> character.


> An example would then be


> debug << "Debug line 1\nDebug line 2" << std::endl;


> which should result in the following output to stderr


> (D) Debug line 1
> (D) Debug line 2


> Is this possible?


Sure. This is a standard application of a filtering streambuf.
See http://kanze.james.neuf.fr/articles/fltrsbf1.html and
http://kanze.james.neuf.fr/articles/fltrsbf2.html.

--
James Kanze (GABI Software) email:(E-Mail Removed)
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert DVD with subtitle stream to DivX with same subtitle stream(selectable) malise Software 1 04-17-2007 09:15 AM
what is the different between byte stream and character stream? dolphin Java 6 03-18-2007 01:58 PM
get stream mode flags from an opened stream Alexander Korsunsky C++ 1 02-17-2007 10:38 AM
How to GET multi-word input from a *file* stream as opposed to a *console* stream? sherifffruitfly@gmail.com C++ 9 04-27-2006 04:14 PM
Doing readline in a thread from a popen4('rsync ...') stream blocks when the stream ends. Rasmusson, Lars Python 1 04-30-2004 08:10 AM



Advertisments