473,799 Members | 3,017 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2329
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...@thismai l.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 objektorientier ter Datenverarbeitu ng
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
1693
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. B_method then uses this A object to call A_method. here is a snippet (pseudo) In class A.cpp:
3
1617
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."); The debug API consists of some complex macros. The macro aquires a debug stream and pipes the second argument into that stream.
4
2126
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 "MyElement",why? Any Suggestions
5
1164
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 = "C:\MyFile.txt" ' create file if not exist If Not File.Exists(strfilename) Then File.CreateText(strFileName)
6
3666
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 I am in debugging mode as indicated by a preprocessor directive: #define DEBUG In other words, I need code which says "Whenever I write debug <<
7
4087
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
2757
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. It should put a blue and yellow box on the page with "This is a test" as part of the picture. But what I get is a broken Gif. The other problem is that I can't view the source???? The view source is disabled for this page. What causes this?
22
4046
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 receive 5 bytes buffer , I call the BeginReceive and then wait on AsyncWaitHandle.WaitOne() but it is signald imidiatly , and the next call to EndReceive return zero bytes length , also the buffer is empty. here is the code: public static byte...
1
3700
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. It gets a XML String from the WS, and I'm supposed to parse this for my project. But I thought that is a very cumbersome process. I'd like a easier method than just parsing the XML and iterating it. I guess most of you would agree with me in this...
0
9685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9538
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10249
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10219
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10025
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7563
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6804
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5461
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3755
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.