![]() |
![]() |
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 SpecifiersThe 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. BackgroundAPG 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 WidthRecall 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 PointersMany 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 MessagesWhen 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. 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):
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
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 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 UsRiverace 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. |