Every C++ program — and every networking app — needs a good logging mechanism. ACE provides you with more than one way to handle such things. Consider your application and how you expect it to grow over time. Your choices range from the simple ACE_DEBUG macros to the highly flexible logging service. Regarding .NET, exception handling is more than just throwing and catching objects. There are many design elements in providing a robust system, and providing a sound exception handling, logging, and tracing schema are among the first steps. In this chapter from “.NET Patterns: Architecture, Design, and Process” book, you’ll learn best practices for determining when to throw, catch, and log your errors.
Exceptions are the things I foolishly left always last. This is a great article that will be very useful in my programming!
Thank you!
Perfect timing! I needed something for error handling and log writing, and this article covered both. I dig the Tracing stuff, too.
a very good document can be found here:
http://www.objectarchitects.de/arcus/cookbook/exhandling/
and here
Its not specifically because its .NET, although these articles seem to be biased towards it around here, its just that I don’t want to see osnews pointing to IBM’s developer site or Sun’s developer site every time they have a new developer article on some obscure topic, anymore than I want to see it pointing to msdn every time it updates like it does now. I’m sure the developers in those languages and others visit their sites frequently as it is, and the rest of us just don’t need to know particularly.
if you don’t like it, go elsewhere. I like it.
I also like to read these articles, although I have currently no intention to do .NET programming (maybe in future, who knows). But it still quite interesting to learn how things are done in different languages and C# seems to be quite nice language also.
From the first page
“However, an important factor in the logging facility’s design is the ability to effectively “no-op” the logging statements at compile time.”
Note that a stream based compile time on/off method works easily
// in header
#ifdef NDEBUG
#define MY_DEBUG if( 0 ) cerr
#else
#define MY_DEBUG if( should_runtime_show() )
get_real_stream_reference();
else
get_null_stream_reference();
#endif
// in program
MY_DEBUG << “foo” << endl;
The first link in the original article “Your choices” does not work. If you have a replacement please post.
I’m interested in ACE_DEBUG but cannot find documentation at the ACE site. In another employment we had a class+macro that allowed us to switch on/off debug logging/tracing messages at run time on a class by class basis and I’m looking for something similar. If you have suggestions please post.