1 //=============================================================================
3 * @file Log_Msg_Test.cpp
5 * This program tests the <ACE_Log_Msg> class in various ways and
6 * also illustrates many of the features of the <ACE_Log_Msg> For
7 * instance, this program tests the <ACE_Log_Msg> abstraction wrt
8 * writing to stderr and to a file. It also tests writing to user
9 * defined callback objects.
11 * @author Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
13 //=============================================================================
16 #include "test_config.h"
18 // FUZZ: disable check_for_streams_include
19 #include "ace/streams.h"
21 #include "ace/FILE_Connector.h"
22 #include "ace/Auto_Ptr.h"
23 #include "ace/Log_Msg_Callback.h"
24 #include "ace/Log_Record.h"
25 #include "ace/OS_NS_fcntl.h"
26 #include "ace/OS_NS_string.h"
27 #include "ace/OS_NS_unistd.h"
28 #include "ace/OS_Memory.h"
29 #include "ace/OS_NS_sys_time.h"
30 #include "ace/OS_NS_time.h"
31 #include "ace/Time_Value.h"
32 #include "ace/Thread.h"
38 ACE_TEXT ("cleanup hook (%P)!\n")));
46 ACE_TEXT ("would block\n")));
49 class Logger
: public ACE_Log_Msg_Callback
52 /// Constructor sets whether we're testing "recursive" callback
54 Logger (bool be_recursive
= true);
57 void log (ACE_Log_Record
&log_record
);
59 void verbose (bool be_verbose
);
62 /// Flag for testing verbose logging.
63 bool verbose_logging_
;
65 /// Flag for testing recursive callback logging.
70 Logger::verbose (bool be_verbose
)
72 this->verbose_logging_
= be_verbose
;
75 Logger::Logger (bool be_recursive
)
76 : recursive_ (be_recursive
)
81 Logger::log (ACE_Log_Record
&log_record
)
83 bool use_log_msg
= false;
86 this->recursive_
= false;
90 if (!this->verbose_logging_
)
94 ACE_TEXT ("Logger::log->%s\n"),
95 log_record
.msg_data ()));
97 #ifdef ACE_LACKS_IOSTREAM_TOTALLY
98 ACE_OS::fprintf (ace_file_stream::instance ()->output_file (),
99 "Recursive Logger callback = %s\n",
100 ACE_TEXT_ALWAYS_CHAR (log_record
.msg_data ()));
102 *ace_file_stream::instance ()->output_file ()
103 << "Recursive Logger callback = "
104 << log_record
.msg_data ()
106 #endif /* ACE_LACKS_IOSTREAM_TOTALLY */
110 ACE_TCHAR verbose_msg
[ACE_Log_Record::MAXVERBOSELOGMSGLEN
];
111 int result
= log_record
.format_msg (ACE_LOG_MSG
->local_host (),
112 ACE_LOG_MSG
->flags (),
114 ACE_Log_Record::MAXVERBOSELOGMSGLEN
);
118 ACE_DEBUG ((LM_DEBUG
,
119 ACE_TEXT ("Logger::log->%s\n"),
122 #ifdef ACE_LACKS_IOSTREAM_TOTALLY
123 ACE_OS::fprintf (ace_file_stream::instance ()->output_file (),
124 "Recursive Logger callback = %s\n",
125 ACE_TEXT_ALWAYS_CHAR (log_record
.msg_data ()));
127 *ace_file_stream::instance ()->output_file ()
128 << "Recursive Logger callback = "
129 << log_record
.msg_data ()
131 #endif /* ACE_LACKS_IOSTREAM_TOTALLY */
135 // Cleanup on the way out.
137 this->recursive_
= true;
141 test_callbacks (void)
143 // This message should show up in stderr.
144 ACE_DEBUG ((LM_DEBUG
,
145 ACE_TEXT ("(%t) first message\n")));
147 ACE_LOG_MSG
->clr_flags (ACE_Log_Msg::OSTREAM
);
149 // This message should not show up anywhere.
150 ACE_DEBUG ((LM_DEBUG
,
151 ACE_TEXT ("(%t) second message\n")));
153 ACE_LOG_MSG
->set_flags (ACE_Log_Msg::MSG_CALLBACK
);
155 // This message should not show up anywhere since no callback object
156 // has been specified.
157 ACE_DEBUG ((LM_DEBUG
,
158 ACE_TEXT ("(%t) third message\n")));
160 // Create a callback object and make it "verbose".
164 // Set the callback object.
165 ACE_LOG_MSG
->msg_callback (&logger
);
167 // This message should show up via the Logger callback.
168 ACE_DEBUG ((LM_DEBUG
,
169 ACE_TEXT ("(%t) forth message\n")));
171 ACE_LOG_MSG
->set_flags (ACE_Log_Msg::VERBOSE_LITE
);
173 // This message should show up via the Logger callback (somewhat
175 ACE_DEBUG ((LM_DEBUG
,
176 ACE_TEXT ("(%t) fifth message\n")));
178 ACE_LOG_MSG
->set_flags (ACE_Log_Msg::VERBOSE
);
180 // This message should show up via the Logger callback (really
182 ACE_DEBUG ((LM_DEBUG
,
183 ACE_TEXT ("(%t) sixth message\n")));
187 // This message should show up via the Logger callback (not
189 ACE_DEBUG ((LM_DEBUG
,
190 ACE_TEXT ("(%t) seventh message\n")));
192 ACE_LOG_MSG
->set_flags (ACE_Log_Msg::OSTREAM
);
194 // This message should show up in stderr and the Logger callback.
195 // The one from the Logger callback will not be verbose, but the one
196 // from stderr should be verbose.
197 ACE_DEBUG ((LM_DEBUG
,
198 ACE_TEXT ("(%t) eighth message\n")));
199 ACE_LOG_MSG
->msg_callback (0);
203 test_log_msg_features (const ACE_TCHAR
*program
)
205 // Note that the default behavior is to log to STDERR...
209 if (ACE_LOG_MSG
->open (program
) == -1)
210 ACE_ERROR ((LM_ERROR
,
211 ACE_TEXT ("cannot open logger!!!\n")));
215 // Check to see what happened.
216 if (ACE_LOG_MSG
->op_status () == -1
217 && ACE_LOG_MSG
->errnum () == EWOULDBLOCK
)
218 ACE_DEBUG ((LM_DEBUG
,
219 ACE_TEXT ("op_status and errnum work!\n")));
221 ACE_ERROR ((LM_ERROR
,
222 ACE_TEXT ("op_status and errnum failed!\n")));
224 const char *badname
= "badname";
226 // We use the DEBUG messages instead of error messages. This is to
227 // help the scripts. If we print out error messages the scripts
228 // start catching them as errors.
229 if (ACE_OS::open (badname
,
230 O_RDONLY
) == ACE_INVALID_HANDLE
)
231 ACE_DEBUG ((LM_DEBUG
,
232 ACE_TEXT ("%n: (%x), can't open %C%r\n"),
237 // Try a log operation that would overflow the logging buffer if not
239 ACE_TCHAR big
[ACE_Log_Record::MAXLOGMSGLEN
+ 1];
241 static const ACE_TCHAR alphabet
[] = ACE_TEXT ("abcdefghijklmnopqrstuvwxyz");
242 size_t j
= ACE_OS::strlen (alphabet
);
243 while (i
< ACE_Log_Record::MAXLOGMSGLEN
)
245 size_t const index
= i
++;
246 big
[index
] = alphabet
[i
% j
];
248 big
[ACE_Log_Record::MAXLOGMSGLEN
] = ACE_TEXT ('\0');
249 ACE_DEBUG ((LM_INFO
, ACE_TEXT ("This is too big:%l %s\n"), big
));
251 ACE_HEX_DUMP((LM_INFO
, (const char*)big
, ACE_Log_Record::MAXLOGMSGLEN
));
253 // Exercise many different combinations of OSTREAM.
255 double f
= 3.1416 * counter
++;
259 ACE_TEXT ("%10f, %*s%s = %d\n"),
266 ACE_LOG_MSG
->set_flags (ACE_Log_Msg::OSTREAM
);
267 ACE_LOG_MSG
->msg_ostream (ace_file_stream::instance ()->output_file ());
269 f
= 3.1416 * counter
;
270 n
= 10000 * counter
++;
273 ACE_TEXT ("%10f, %*s%s = %d\n"),
280 ACE_LOG_MSG
->clr_flags (ACE_Log_Msg::OSTREAM
);
282 // The next two messages shouldn't print.
284 f
= 3.1416 * counter
;
285 n
= 10000 * counter
++;
288 ACE_TEXT ("%10f, %*s%s = %d\n"),
295 f
= 3.1416 * counter
;
296 n
= 10000 * counter
++;
299 ACE_TEXT ("%10f, %*s%s = %d\n"),
306 ACE_LOG_MSG
->set_flags (ACE_Log_Msg::OSTREAM
);
308 f
= 3.1416 * counter
;
309 n
= 10000 * counter
++;
312 ACE_TEXT ("%10f, %*s%s = %d\n"),
319 static int array
[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048};
321 // Print out the binary bytes of the array in hex form.
322 ACE_LOG_MSG
->log_hexdump (LM_DEBUG
,
326 // Disable the LM_DEBUG and LM_INFO messages.
327 u_long priority_mask
=
328 ACE_LOG_MSG
->priority_mask (ACE_Log_Msg::PROCESS
);
329 ACE_CLR_BITS (priority_mask
,
331 ACE_LOG_MSG
->priority_mask (priority_mask
,
332 ACE_Log_Msg::PROCESS
);
335 ACE_TEXT ("This LM_INFO message should not print!\n")));
336 ACE_DEBUG ((LM_DEBUG
,
337 ACE_TEXT ("This LM_DEBUG message should not print!\n")));
339 ACE_SET_BITS (priority_mask
,
341 ACE_LOG_MSG
->priority_mask (priority_mask
,
342 ACE_Log_Msg::PROCESS
);
345 ACE_TEXT ("This LM_INFO message should print!\n")));
346 ACE_DEBUG ((LM_DEBUG
,
347 ACE_TEXT ("This LM_DEBUG message should not print!\n")));
349 ACE_CLR_BITS (priority_mask
, LM_INFO
);
350 ACE_LOG_MSG
->priority_mask (priority_mask
,
351 ACE_Log_Msg::PROCESS
);
354 ACE_TEXT ("This LM_INFO message should not print!\n")));
355 ACE_DEBUG ((LM_DEBUG
,
356 ACE_TEXT ("This LM_DEBUG message should not print!\n")));
359 // For testing how many log records has been output
360 class Log_Count
: public ACE_Log_Msg_Callback
365 Log_Count () : count_(0)
370 void log (ACE_Log_Record
&)
382 test_acelib_category()
388 ACE_LOG_MSG
->msg_callback (&counter
);
390 // Disable the LM_DEBUG and LM_INFO messages.
391 u_long priority_mask
=
392 ACE_LOG_MSG
->priority_mask (ACE_Log_Msg::PROCESS
);
393 ACE_CLR_BITS (priority_mask
,
395 ACE_Log_Category::ace_lib().priority_mask (priority_mask
);
397 ACELIB_DEBUG ((LM_INFO
,
398 ACE_TEXT ("This LM_INFO message should not print!\n")));
399 ACELIB_DEBUG ((LM_DEBUG
,
400 ACE_TEXT ("This LM_DEBUG message should not print!\n")));
402 if (counter
.count() != 0)
408 ACE_TEXT ("This LM_INFO message should print!\n")));
409 ACE_DEBUG ((LM_DEBUG
,
410 ACE_TEXT ("This LM_DEBUG message should print!\n")));
412 if (counter
.count() != 2)
417 ACE_SET_BITS (priority_mask
,
419 ACE_Log_Category::ace_lib().priority_mask (priority_mask
);
421 ACELIB_DEBUG ((LM_INFO
,
422 ACE_TEXT ("This LM_INFO message should print!\n")));
424 if (counter
.count() != 3)
429 ACELIB_DEBUG ((LM_DEBUG
,
430 ACE_TEXT ("This LM_DEBUG message should not print!\n")));
432 if (counter
.count() != 3)
437 ACE_CLR_BITS (priority_mask
, LM_INFO
);
438 ACE_Log_Category::ace_lib().priority_mask (priority_mask
);
440 ACELIB_DEBUG ((LM_INFO
,
441 ACE_TEXT ("This LM_INFO message should not print!\n")));
442 ACELIB_DEBUG ((LM_DEBUG
,
443 ACE_TEXT ("This LM_DEBUG message should not print!\n")));
445 if (counter
.count() != 3)
452 ACE_DEBUG((LM_DEBUG
, "All ace lib category log passed\n"));
455 ACE_ERROR((LM_ERROR
, "Some ace lib category log failed\n"));
457 ACE_LOG_MSG
->msg_callback (0);
464 // This message should show up in the log file.
465 ACE_DEBUG ((LM_DEBUG
,
466 ACE_TEXT ("first message\n")));
468 ACE_LOG_MSG
->clr_flags (ACE_Log_Msg::OSTREAM
);
470 // This message should not show up anywhere.
471 ACE_DEBUG ((LM_DEBUG
,
472 ACE_TEXT ("second message\n")));
474 ACE_LOG_MSG
->set_flags (ACE_Log_Msg::OSTREAM
);
476 #if !defined (ACE_LACKS_IOSTREAM_TOTALLY)
477 // Create a persistent store.
478 const ACE_TCHAR
*filename
= ACE_TEXT ("output");
479 ofstream
myostream (ACE_TEXT_ALWAYS_CHAR (filename
), ios::out
| ios::trunc
);
482 if (myostream
.bad ())
485 OFSTREAM
*old_stream
= ace_file_stream::instance ()->output_file ();
487 ACE_LOG_MSG
->msg_ostream (&myostream
);
489 // This message should show up in the ostream.
490 ACE_DEBUG ((LM_DEBUG
,
491 ACE_TEXT ("fourth message\n")));
492 // Set the ostream back to the test's log file.
493 ACE_LOG_MSG
->msg_ostream (old_stream
);
494 // Now close the ostream file and check its contents.
497 ACE_FILE_Connector connector
;
499 ACE_FILE_Addr
file_addr (filename
);
502 if (connector
.connect (file
, file_addr
) == -1)
504 ACE_ERROR_RETURN ((LM_ERROR
,
505 ACE_TEXT ("connect failed for %p\n"),
510 #if !defined (ACE_VXWORKS) && !defined (ACE_HAS_PHARLAP) || (defined(ACE_VXWORKS) && (ACE_VXWORKS > 0x690))
511 # define TEST_CAN_UNLINK_IN_ADVANCE
514 #if defined (TEST_CAN_UNLINK_IN_ADVANCE)
515 // Unlink this file right away so that it is automatically removed
516 // when the process exits.Ignore error returns in case this operation
518 ACE_OS::unlink(filename
);
522 if (file
.get_info (info
) == -1)
524 ACE_ERROR_RETURN ((LM_ERROR
,
525 ACE_TEXT ("get_info failed on %p\n"),
530 // Allocate the input buffer
532 ACE_NEW_RETURN (buffer
,
533 char[info
.size_
+ 1],
535 // Make sure <buffer> is released automagically.
536 ACE_Auto_Basic_Array_Ptr
<char> b (buffer
);
538 // Read the file into the buffer.
539 ssize_t size
= file
.recv (buffer
,
541 if (size
!= info
.size_
)
543 ACE_ERROR_RETURN ((LM_ERROR
,
544 ACE_TEXT ("Read %d bytes, rather than expected %d bytes\n"),
549 // Make sure to NUL-terminate this turkey!
553 ACE_DEBUG ((LM_DEBUG
,
557 #if !defined (TEST_CAN_UNLINK_IN_ADVANCE)
559 if (file
.unlink () == -1)
560 ACE_ERROR_RETURN ((LM_ERROR
,
561 ACE_TEXT ("unlink failed for %p\n"),
562 file_addr
.get_path_name ()),
566 #endif /* ACE_LACKS_IOSTREAM_TOTALLY */
568 // This message should show up in stderr and the ostream (without
569 // ACE_LACKS_IOSTREAM_TOTALLY).
570 ACE_DEBUG ((LM_DEBUG
,
571 ACE_TEXT ("fifth message\n")));
577 // For testing the format specifiers, a class is defined as a callback
578 // mechanism. It will get the formatted messages and check them for
579 // correctness. The test_format_specs() function will set the first
580 // few characters to say which test is being run, and the Log_Spec_Verify
581 // class will use that to decide how to verify the results.
583 class Log_Spec_Verify
: public ACE_Log_Msg_Callback
586 Log_Spec_Verify (bool be_recursive
= true) : fail_ (0), tests_ (0), recursive_ (be_recursive
) {};
589 void log (ACE_Log_Record
&log_record
);
594 /// Count how many tests failed.
597 /// Count how many tests we run
604 Log_Spec_Verify::log (ACE_Log_Record
&log_record
)
606 bool use_log_msg
= false;
607 if (this->recursive_
)
609 this->recursive_
= false;
615 #if !defined (ACE_LACKS_IOSTREAM_TOTALLY)
616 *ace_file_stream::instance ()->output_file ()
617 << "Logger callback = "
618 << log_record
.msg_data ()
620 #endif /* ACE_LACKS_IOSTREAM_TOTALLY */
624 const ACE_TCHAR
*b
= log_record
.msg_data ();
625 const ACE_TCHAR
*expect
= 0;
629 if (ACE_OS::strncmp (b
, ACE_TEXT ("l1:"), 3) == 0)
631 expect
= ACE_TEXT ("42");
634 else if (ACE_OS::strncmp (b
, ACE_TEXT ("l2:"), 3) == 0)
636 expect
= ACE_TEXT (" 42");
639 else if (ACE_OS::strncmp (b
, ACE_TEXT ("l3N1:"), 4) == 0)
641 expect
= ACE_TEXT ("0042,Log_Msg");
644 else if (ACE_OS::strncmp (b
, ACE_TEXT ("l4:"), 3) == 0)
647 // Check if we have a string, exact length could vary
648 if (b
!= log_record
.msg_data () && ACE_OS::strlen (b
) < 15)
650 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("ERROR: Test %s failed; expected %d\n"),
651 log_record
.msg_data (), ACE_OS::strlen (b
)));
655 else if (ACE_OS::strncmp (b
, ACE_TEXT ("l5:"), 3) == 0)
658 switch (log_record
.type())
660 case (LM_SHUTDOWN
): expect
= ACE_TEXT("S"); break;
661 case (LM_TRACE
): expect
= ACE_TEXT("T"); break;
662 case (LM_DEBUG
): expect
= ACE_TEXT("D"); break;
663 case (LM_INFO
): expect
= ACE_TEXT("I"); break;
664 case (LM_NOTICE
): expect
= ACE_TEXT("N"); break;
665 case (LM_WARNING
): expect
= ACE_TEXT("W"); break;
666 case (LM_STARTUP
): expect
= ACE_TEXT("U"); break;
667 case (LM_ERROR
): expect
= ACE_TEXT("E"); break;
668 case (LM_CRITICAL
): expect
= ACE_TEXT("C"); break;
669 case (LM_ALERT
): expect
= ACE_TEXT("A"); break;
670 case (LM_EMERGENCY
): expect
= ACE_TEXT("!"); break;
671 default: expect
= ACE_TEXT("?"); break;
674 else if (ACE_OS::strncmp (b
, ACE_TEXT ("l6:"), 3) == 0)
676 // After a l6 there shouldn't be a space
678 if (b
!= log_record
.msg_data () && ACE_OS::strncmp (b
, ACE_TEXT (" "), 1) == 0)
680 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("ERROR: Test %s failed; expected no space before the time\n"),
681 log_record
.msg_data ()));
687 ACE_ERROR ((LM_ERROR
,
688 ACE_TEXT ("Log_Spec_Verify, unrecognized test: %s\n"),
693 if (b
!= log_record
.msg_data () && expect
&& ACE_OS::strcmp (b
, expect
) != 0)
695 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("ERROR: Test %s failed; expected %s\n"),
696 log_record
.msg_data (), expect
));
701 // Cleanup on the way out.
703 this->recursive_
= true;
707 Log_Spec_Verify::result (void)
709 if (this->fail_
== 0)
710 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("All logging specifier tests passed.\n")));
712 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("%d logging specifier tests failed!\n"),
715 if (this->tests_
!= 19)
717 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("Expected number of tests run is %d, not 19!\n"),
725 test_format_specs (void)
727 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("l1:%l\n")));
728 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("l2:%5l\n")));
729 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("l3N1:%0*l,%.7N\n"), 4));
730 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("%*ISTART INDENTING %{\n"), 4));
731 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("%IONE%{\n")));
732 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("%ITWO%{\n")));
733 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("%ITHREE%*Iwp == 1\n"), 1));
734 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("%}%ITWO\n")));
735 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("%}%IONE\n")));
736 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("%}%IENDINDENTING\n")));
737 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("%W\n"), ACE_TEXT_WIDE ("My string test\n")));
738 ACE_WCHAR_T
*nill_string
= 0;
739 char* char_nill_string
= 0;
740 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("%W\n"), nill_string
));
741 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("%s\n"), nill_string
));
742 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("%C\n"), char_nill_string
));
743 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("%m %p\n"), nill_string
));
745 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("%m %p\n"), ACE_TEXT("perror")));
746 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("%S\n"), SIGINT
));
747 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("%S\n"), ACE_NSIG
));
748 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("thread id %t\n")));
750 Log_Spec_Verify verifier
;
752 ACE_LOG_MSG
->msg_callback (&verifier
);
753 ACE_LOG_MSG
->clr_flags (ACE_Log_Msg::VERBOSE_LITE
);
754 ACE_LOG_MSG
->clr_flags (ACE_Log_Msg::VERBOSE
);
755 ACE_LOG_MSG
->linenum (42);
756 ACE_LOG_MSG
->file ("Log_Msg_Test.cpp");
758 #ifdef ACE_LACKS_VA_FUNCTIONS
761 #define LOG_ARGS(X) X
764 ACE_LOG_MSG
->log
LOG_ARGS ((LM_DEBUG
, ACE_TEXT ("l1:%l")));
765 ACE_LOG_MSG
->log
LOG_ARGS ((LM_DEBUG
, ACE_TEXT ("l2:%5l")));
766 ACE_LOG_MSG
->log
LOG_ARGS ((LM_DEBUG
, ACE_TEXT ("l3N1:%0*l,%.7N"), 4));
767 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("l4:%T")));
769 ACE_LOG_MSG
->priority_mask (LM_SHUTDOWN
|
780 ACE_Log_Msg::PROCESS
);
781 ACE_DEBUG ((LM_SHUTDOWN
, ACE_TEXT ("l5:%.1M")));
782 ACE_DEBUG ((LM_TRACE
, ACE_TEXT ("l5:%.1M")));
783 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("l5:%.1M")));
784 ACE_DEBUG ((LM_INFO
, ACE_TEXT ("l5:%.1M")));
785 ACE_DEBUG ((LM_NOTICE
, ACE_TEXT ("l5:%.1M")));
786 ACE_DEBUG ((LM_WARNING
, ACE_TEXT ("l5:%.1M")));
787 ACE_DEBUG ((LM_STARTUP
, ACE_TEXT ("l5:%.1M")));
788 ACE_DEBUG ((LM_ERROR
, ACE_TEXT ("l5:%.1M")));
789 ACE_DEBUG ((LM_CRITICAL
, ACE_TEXT ("l5:%.1M")));
790 ACE_DEBUG ((LM_ALERT
, ACE_TEXT ("l5:%.1M")));
791 ACE_DEBUG ((LM_EMERGENCY
, ACE_TEXT ("l5:%.1M")));
793 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("l6:%D\n")));
794 ACE_Time_Value tv
= ACE_OS::gettimeofday ();
795 tv
+= ACE_Time_Value (25*60*60); // + 25 hours
796 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("l6:%#D\n"), &tv
));
798 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("l6:%T\n")));
799 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("l6:%#T\n"), &tv
));
801 ACE_LOG_MSG
->msg_ostream (ace_file_stream::instance ()->output_file ());
802 ACE_LOG_MSG
->msg_callback (0);
803 ACE_LOG_MSG
->set_flags (ACE_Log_Msg::OSTREAM
);
804 ACE_LOG_MSG
->set_flags (ACE_Log_Msg::VERBOSE_LITE
);
806 return verifier
.result ();
812 run_main (int argc
, ACE_TCHAR
*argv
[])
814 ACE_START_TEST (ACE_TEXT ("Log_Msg_Test"));
818 ACE_DEBUG ((LM_DEBUG
,
819 ACE_TEXT ("**** running ostream test\n")));
821 // Test the <ACE_Log_Msg> abstraction wrt writing to stderr and to a
825 ACE_DEBUG ((LM_DEBUG
,
826 ACE_TEXT ("%M **** running callback test\n")));
828 // Test the <ACE_Log_Msg> callback mechanism.
831 ACE_DEBUG ((LM_DEBUG
,
832 ACE_TEXT ("**** running features test\n")));
834 // Test various features of the <ACE_Log_Msg>.
835 test_log_msg_features ((argc
> 0 ? argv
[0] : ACE_TEXT ("program")));
837 // Test the format specifiers
839 // Restore this mask so diags and the shutdown message will print correctly!
840 ACE_LOG_MSG
->priority_mask (ACE_LOG_MSG
->priority_mask () | LM_DEBUG
| LM_ERROR
,
841 ACE_Log_Msg::PROCESS
);
843 ACE_DEBUG ((LM_DEBUG
,
844 ACE_TEXT ("**** running format specifiers test\n")));
846 if (status
+= test_format_specs ())
848 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("logging specifier tests failed!\n")));
852 status
+= test_acelib_category();