473,386 Members | 1,819 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,386 software developers and data experts.

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 2303
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: marcus | last post by:
I have this class A that contains a method A_method that opens a file and does fgets. I also have a template class B that contains a method B_method that takes a class A object as template type....
3
by: Thomas Lorenz | last post by:
Hello NG, I'm working on a larger C++ project with it's own debug functionality. The typical debug call looks like this: DEBUG(WARNING, "An error " << getErrorCategory() << " occured."); ...
4
by: Raed Sawalha | last post by:
I'm trying to create Element as following name MyElement:InitialName XmlElement elem = doc.CreateElement("MyElement:InitialName"); when generate the XML the tag is truncated as ONLY...
5
by: VB Programmer | last post by:
I want to write to a simple text file. If it doesn't exist I want to create it first. Here is my code (portion): Imports System.IO ' at the top of the class : : Dim strFileName As String =...
6
by: pauldepstein | last post by:
To help me debug, I am writing a lot of information into a stream which I call debug. However, because of the large amount of time taken to print this information, I only want this printed while...
7
by: Bernard Bourée | last post by:
In order to trace my job I placed some Debug.Writeline in my code but they don't appear in the output window! How to solve it? Thanks Bernard
4
by: tshad | last post by:
I am trying to set up an Image authorization where you type in the value that is in a picture to log on to our site. I found a program that is supposed to do it, but it doesn't seem to work. ...
22
by: semedao | last post by:
Hi , I am using asyc sockets p2p connection between 2 clients. when I debug step by step the both sides , i'ts work ok. when I run it , in somepoint (same location in the code) when I want to...
1
by: OutlookCoder | last post by:
Hi All, I have a simple question. Howto consume a .NET webservice form VB6. I have tried very many methods. I currently use MSXML. Here is the piece of code that I use. This works flawlessly....
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.