logging debug messages

  • Thread starter Thread starter byaarov
  • Start date Start date
B

byaarov

How do I display debug messages from a Win32 application project
(visual studio c++). I'd like to print the messages in the output
window of visual studio
 
How do I display debug messages from a Win32 application project
(visual studio c++). I'd like to print the messages in the output
window of visual studio

Just add a new TraceListener to the Debug.Listeners collection. You can
then write the output of the Debug class wherever you like.
 
Just add a new TraceListener to the Debug.Listeners collection. You can
then write the output of the Debug class wherever you like.

I just have a simple console application written in C... is there a
simpler way to do this? I remember a while back there was a simple
function like DebugMessage or LogMessage or something like that, which
just wrote the input to the console window of the visual C debugger...
is there still something like that available?
 
I just have a simple console application written in C... is there a
simpler way to do this? I remember a while back there was a simple
function like DebugMessage or LogMessage or something like that, which
just wrote the input to the console window of the visual C debugger...
is there still something like that available?

It sounds like you're looking for OutputDebugString()

Dave
 
I just have a simple console application written in C... is there a
simpler way to do this? I remember a while back there was a simple
function like DebugMessage or LogMessage or something like that, which
just wrote the input to the console window of the visual C debugger...
is there still something like that available?

I don't understand your question. Your original post, to me, implied that
you had debug messages already in the Output window, and you wanted to
display them somewhere else (like print them, for example).

While OutputDebugString() works in some contexts, it's not the .NET way to
do things. There is a perfectly good, just-as-easy-to-use Debug class
that is available in .NET. If you are simply trying to find out how to
get messages to the Output window in the first place, then Debug.Write()
and Debug.WriteLine() are what you want.

I cannot imagine anything being simpler. OutputDebugString() certainly is
no simpler (though it's not much more complicated either).

If you then also want those messages logged elsewhere somehow, you can add
a TraceListener to the Debug.Listeners collection. Perhaps you don't need
this, but if you do it's simple to add. Assuming you are using the .NET
Debug class in the first place, of course.

Pete
 
Peter Duniho said:
While OutputDebugString() works in some contexts, it's not the .NET way to
do things. There is a perfectly good, just-as-easy-to-use Debug class
that is available in .NET. If you are simply trying to find out how to
get messages to the Output window in the first place, then Debug.Write()
and Debug.WriteLine() are what you want.

But there is no .NET Debug class available to an MFC program!

-- David
 
But there is no .NET Debug class available to an MFC program!

So? The OP never said anything about MFC, and this is a .NET Framework
programming newsgroup.

You are grossly mistaken if you are reading this newsgroup for information
about MFC programming topics.

Pete
 
Peter Duniho said:
So? The OP never said anything about MFC, and this is a .NET Framework
programming newsgroup.

You are grossly mistaken if you are reading this newsgroup for information
about MFC programming topics.

Look at the newsgroups that the thread is posted to.

-- David
 
Peter Duniho said:
So? The OP never said anything about MFC, and this is a .NET Framework
programming newsgroup.

You are grossly mistaken if you are reading this newsgroup for information
about MFC programming topics.

No he isn't. The OP did a crosspost without follow-up.

Hans
 
Look at the newsgroups that the thread is posted to.

Yes? You'll note that one of them is the
microsoft.public.dotnet.framework newsgroup. Just because someone can't
be bothered to not cross-pollute newsgroups, I'm expected to only answer
if my answer pertains to the *other* newsgroup(s) in the list?

I don't think so.
 
Peter Duniho said:
Yes? You'll note that one of them is the
microsoft.public.dotnet.framework newsgroup. Just because someone can't
be bothered to not cross-pollute newsgroups, I'm expected to only answer
if my answer pertains to the *other* newsgroup(s) in the list?

I don't think so.

Your other recent posts make you seem like a decent guy, so I'll cut you a
break. I've removed the MFC newsgroup from this answer as you should have
done in yours.

-- David
 
Peter said:
Yes? You'll note that one of them is the
microsoft.public.dotnet.framework newsgroup. Just because someone can't
be bothered to not cross-pollute newsgroups, I'm expected to only answer
if my answer pertains to the *other* newsgroup(s) in the list?

I don't think so.

Just another example of why cross-posting is almost always a bad idea.
 
Back
Top