diff options
author | nw1 <nw1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-06-10 06:57:13 +0000 |
---|---|---|
committer | nw1 <nw1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-06-10 06:57:13 +0000 |
commit | 40d19f0b25b54205d1e7aebe6f46acdcae9aa074 (patch) | |
tree | 4b940f9e6433fb4624eedaa4cc6da541b7356da4 /examples | |
parent | d60818dd178e4fb76fe5f4455352f7ee05950859 (diff) | |
download | ATCD-40d19f0b25b54205d1e7aebe6f46acdcae9aa074.tar.gz |
*** empty log message ***
Diffstat (limited to 'examples')
-rw-r--r-- | examples/Log_Msg/README | 49 | ||||
-rw-r--r-- | examples/Log_Msg/test_log_msg.cpp | 41 |
2 files changed, 79 insertions, 11 deletions
diff --git a/examples/Log_Msg/README b/examples/Log_Msg/README index 156a3c33432..668014bacd4 100644 --- a/examples/Log_Msg/README +++ b/examples/Log_Msg/README @@ -6,3 +6,52 @@ Log_Msg class to record various information. writes some messages using different log priorities and output stream. + You can invoke the program with or without command + parameters. When invoked with any parameters like, + + ./Log_Msg foobar + + the log messages are direct to stdout (or, ostream in C++.) + In this case, the program simulates an error EWOULDBLOCK and + write an error log to stdout as, + + would block + op_status and errnum work! + + When invoked without any parameters, except does the same + test as above but logs to default log stream "stderr," the + program also demonstrates logging messages/errors with + different priority and changing the logging destination. A + sample output is, + + would block + op_status and errnum work! + 3.141600, hello = 10000 + 6.283200, world = 20000 + 6.283200, world = 20000 + 9.424800, world = 30000 + 12.566400, world = 40000 + 15.708000, world = 50000 + HEXDUMP 48 bytes + 01 00 00 00 02 00 00 00 04 00 00 00 08 00 00 00 ................ + 10 00 00 00 20 00 00 00 40 00 00 00 80 00 00 00 .... ...@....... + 00 01 00 00 00 02 00 00 00 04 00 00 00 08 00 00 ................ + ./Log_Msg.EXE: (2710), badname: Function not implemented + + In this test, there are two lines containing "world` = + 20000." That's because in the program, both stderr and + stdout are "turned on" for logging before writing this log + message. The line containing "world = 30000" is written to + stdout only. Rest of the lines are all to the stderr. You + can examine this behavior by redirecting stderr and stdout + to different files. + + The HEXDUMP output shows how to take an arbitrary object and + hexdump its content for debugging. Finally, the program + shows an ordinary use case of logging error messages using + the ACE_ERROR macro. + + If you look into the program, there is also a demonstration + showing how to disable certain priorities of error message + temporarily. + diff --git a/examples/Log_Msg/test_log_msg.cpp b/examples/Log_Msg/test_log_msg.cpp index 6216aa38c36..7beef0e345d 100644 --- a/examples/Log_Msg/test_log_msg.cpp +++ b/examples/Log_Msg/test_log_msg.cpp @@ -1,6 +1,23 @@ -// Test the Log_Msg abstraction. // $Id$ +// ============================================================================ +// +// = LIBRARY +// examples/Log_Msg +// +// = FILENAME +// test_log_msg.cpp +// +// = DESCRIPTION +// This program tests the Log_Msg abstraction and demontrates +// several use cases. +// +// = AUTHOR +// Douglas Schmidt +// +// ============================================================================ + + #include "ace/OS.h" static void @@ -21,6 +38,8 @@ main (int argc, char *argv[]) { // Note that the default behavior is to log to STDERR... + int counter = 1 ; + if (argc > 1) { if (ACE_LOG_MSG->open (argv[0], ACE_Log_Msg::OSTREAM) == -1) @@ -50,32 +69,32 @@ main (int argc, char *argv[]) // Exercise many different combinations of STDERR and OSTREAM. - ACE_DEBUG ((LM_INFO, "%f, %*s%s = %d\n", - 3.1416, 8, "", "hello", 10000)); + ACE_DEBUG ((LM_INFO, "%10f, %*s%s = %d\n", + 3.1416 * counter++, 8, "", "hello", 10000)); ACE_LOG_MSG->set_flags (ACE_Log_Msg::OSTREAM); ACE_LOG_MSG->msg_ostream (&cout); - ACE_DEBUG ((LM_INFO, "%f, %*s%s = %d\n", - 3.1416 * 3.1416, 8, "", "world", 20000)); + ACE_DEBUG ((LM_INFO, "%10f, %*s%s = %d\n", + 3.1416 * counter, 8, "", "world", 10000 * counter++)); ACE_LOG_MSG->clr_flags (ACE_Log_Msg::STDERR); - ACE_DEBUG ((LM_INFO, "%f, %*s%s = %d\n", - 3.1416 * 3.1416, 8, "", "world", 20000)); + ACE_DEBUG ((LM_INFO, "%10f, %*s%s = %d\n", + 3.1416 * counter, 8, "", "world", 10000 * counter++)); ACE_LOG_MSG->msg_ostream (0); ACE_LOG_MSG->set_flags (ACE_Log_Msg::STDERR); - ACE_DEBUG ((LM_INFO, "%f, %*s%s = %d\n", - 3.1416 * 3.1416, 8, "", "world", 20000)); + ACE_DEBUG ((LM_INFO, "%10f, %*s%s = %d\n", + 3.1416 * counter, 8, "", "world", 10000 * counter++)); ACE_LOG_MSG->clr_flags (ACE_Log_Msg::OSTREAM); ACE_LOG_MSG->msg_ostream (&cerr); - ACE_DEBUG ((LM_INFO, "%f, %*s%s = %d\n", - 3.1416 * 3.1416, 8, "", "world", 20000)); + ACE_DEBUG ((LM_INFO, "%10f, %*s%s = %d\n", + 3.1416 * counter, 8, "", "world", 10000 * counter++)); static int array[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048}; |