ACE Newsletter for December 2004

Welcome to the December 2004 edition of Riverace's ACE News and Tips newsletter. This issue contains a helpful review of some of the less-known ACE Logging directives, news about what's coming up in the next ACE release, and a note about the latest ACE Fix Kit releases.

Please forward this newsletter to anyone you think may be interested! Anyone who wishes to receive their own copy of this newsletter can subscribe at http://www.riverace.com/subscribe2/index.mv. If you no longer wish to subscribe, removal directions are at the bottom of this page.

Please reply with any feedback you have on this newsletter, as well as ideas for information you'd like to see in upcoming newsletters. We want to be as helpful as possible, so please let us know how we can do that.


ACE Tip: Useful But Not-Often-Used Logging Format Specifiers

The ACE Logging facility is a very useful way to log debugging, informational, and diagnostic information across platforms. It has a rich set of methods for directing logging output to a variety of logging sinks, safety in multithreaded environments, and a wide variety of logging format specifiers. This article reviews some of the more helpful, but not-well-known, logging format specifiers.

Background

APG chapter 3 contains a full description of ACE's logging facility and directions for its use. The ACE_Log_Msg::log() methods allow users to format logged information using format specifiers that look very much like printf() format specifiers. The common formats like %d and %s work as you'd expect (a decimal integer and a nul-terminated string, respectively). Additionally, the printf()-specified field width and fill modifiers work just like in printf().

Strings and Character Width

Recall our discussion from the November 2004 newsletter regarding ACE's facilities for using narrow and wide characters. The %s format specifier is usually used to format a nul-terminated character string. There is a twist in ACE however. In ACE_Log_Msg formatting, %s formats a 0-terminated ACE_TCHAR string. This changes to match the character width of ACE_TCHAR (narrow when ACE_USES_WCHAR is not set, and wide when ACE_USES_WCHAR is set).

In cases where a char array needs to be logged, regardless of the ACE_USES_WCHAR setting, use the %C format specifier. That accepts a char* always. For logging wchar_t* strings regardless of ACE_USES_WCHAR, use %W.

Logging Pointers

Many applications are aided by the logging of pointers. This is usually accomplished by using a printf() format specifier %x or %d. However, both of these assume an int and code that uses these format specifiers only work when a pointer is the same size as an int, something that is less common these days with 64-bit memory models.

ACE offers a ACE_Log_Msg format specifier intended for logging pointers: %@. Here is an example of its use:

 Object *obj;

 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("obj is at %@\n"), obj));

The %@ specifier logs the pointer in hexadecimal form, like %x, but always uses the correct data type size for pointers.

Error Messages

When an error occurs, it is often desireable to display the corresponding system-specified error message. Using the C library, you would often use perror() to do this. ACE makes this easy as well with the %p specifier. You use this like:

 if (sock.recv (buff, sizeof (buff)) == -1)

   ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("recv")))

As in perror(), this would print "recv: " followed by the system message corresponding to errno.
Note that the argument to %p is an ACE_TCHAR string. Always use ACE_TEXT() to be sure your string is correctly sized.

For examples of these and other facilities, please see the ACE test suite source code in ACE_wrappers/tests or the APG example source code in ACE_wrappers/examples/APG.

If you have more questions about ACE logging usage and ACE, please feel free to file a support request to get further clarification and information. If you're not a Riverace support customer, you can learn more about our support services at http://www.riverace.com/support.htm.


ACE.next: What's New?

The ACE development community is hard at work on the next version of ACE. Here are some of the things you can look forward to (items in bold are new or changed since last month):

  • Native library path-searching. Previous ACE versions's implementation of ACE_DLL (used in loading dynamic services) implemented a search of the configured path-search to try and locate the desired library file (DLL) and then used the full pathname to load the library. This skirted some platforms's rules for path search and security settings. This has been changed in the next ACE version to make use of all of the native platform's path-search and security facilities.
  • Improved wide-character support. Wide-character support has been included in ACE for many years on Windows (also known as Unicode builds). However, wide-character support for POSIX platforms has been sorely lacking. As ACE's reach expands, this has become a more important issue. Riverace is leading the completion of wide-character support in the next version of ACE. This support is also available now in the ACE 5.4b fix kit.
  • GNU autotools support. Riverace is the lead developer in charge of adding auto-configure support to ACE. For native-build, non-Windows systems, autoconf will very likely become the way to configure and build ACE. This will help insure that ACE uses the latest features available on each supported platform, and reduce the work required to build ACE. No more picking the right config.h or platform_macros.GNU file. Just do ./configure then make. Ahhh...
  • New compiler support. Support for g++ 3.4 and Microsoft Visual C++ 2005 are being added.
  • Newer C++ Features Being Used. As the range of ACE-supported compilers matures and older compilers are taken out of service, ACE can make more use of newer C++ features while still maintaining its stellar portability record. For example, many methods that returned 1 or 0 as an int now return bool. Small steps, yes, but significant ones. You'll see more modern C++ usage as time goes on.

New ACE Fix Kits Released!

Riverace released ACE versions 5.3e and 5.4b, containing lots of new fixes and improvements to the ACE 5.3 and 5.4 release series, respectively. These kits provide fixes to previously released ACE versions, and are not beta test kits in the ACE develoment stream. The small price for these kits provides you with tremendous value in the ability to maintain stability in your projects while picking up important fixes to ACE.


New Project Coming Up?

If you're planning a new project to start soon, or find yourself grappling with how to apply ACE to your current project, remember that Riverace provides world-class development and consulting services with special expertise in ACE. We can help you be sure that your new system is designed to take full advantage of ACE's power and flexibility, getting your system delivered in the shortest possible time and with the highest level of quality. Please contact Steve Huston at 888-384-8154 (toll-free in the US) or +1 508-541-9180 to discuss how Riverace can help you.

Useful ACE Information

  • Riverace-supported ACE Releases (don't forget, ACE Annual Support customers get no-charge access to all Fix Kits!)
  5.3 (January 15, 2003) Fix Kits: a, b, c, e
  5.4 (January 14, 2004) Fix Kits: a, b

Quotables

"I also wanted to take this opportunity to express my appreciation for the quality and responsiveness of your organization.  It is a very rare pleasure to work with an organization that provides in-depth technical support while remaining strongly customer focused - a fact you clearly demonstrate on every interaction.  With your help, we have been able to dramatically improve our development schedule while reducing the overall cost and resources required.  Riverace has exceeded our expectations without exception."

Christopher W. Midgley
Chief Technology Officer
LiveVault Corporation

This Newsletter...

... is produced by Riverace Corporation to educate the ACE user community about ACE and available ACE resources, give tips on how to use ACE more effectively, and explain how Riverace can help you make the most of this powerful toolkit.

About Us

Riverace Corporation is the premier support service provider for the ACE toolkit worldwide. Steve Huston, Riverace's President/CEO and founder, has over 20 years' experience developing network protocols and applications. He has coauthored three books on ACE's design and usage and is considered an expert by ACE users around the world. Riverace has been focused on providing world-class technical support and consulting services for ACE since 1997.