468,289 Members | 1,893 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,289 developers. It's quick & easy.

Creating a debug stream

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. "
Sep 11 '08 #1
2 2063
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
Sep 11 '08 #2
On Sep 11, 7:01 pm, ciccio <nos...@thismail.comwrote:
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:ja*********@gmail.com
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
Sep 11 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by marcus | last post: by
3 posts views Thread by Thomas Lorenz | last post: by
4 posts views Thread by Raed Sawalha | last post: by
5 posts views Thread by VB Programmer | last post: by
6 posts views Thread by pauldepstein | last post: by
7 posts views Thread by Bernard Bourée | last post: by
4 posts views Thread by tshad | last post: by
reply views Thread by NPC403 | last post: by
2 posts views Thread by MrBee | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.