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 //=============================================================================
15 #include "test_config.h"
17 // FUZZ: disable check_for_streams_include
18 #include "ace/streams.h"
20 #include "ace/FILE_Connector.h"
22 #include "ace/Log_Msg_Callback.h"
23 #include "ace/Log_Record.h"
24 #include "ace/OS_NS_fcntl.h"
25 #include "ace/OS_NS_string.h"
26 #include "ace/OS_NS_unistd.h"
27 #include "ace/OS_Memory.h"
28 #include "ace/OS_NS_sys_time.h"
29 #include "ace/OS_NS_time.h"
30 #include "ace/Time_Value.h"
31 #include "ace/Thread.h"
37 ACE_TEXT ("cleanup hook (%P)!\n")));
45 ACE_TEXT ("would block\n")));
48 class Logger
: public ACE_Log_Msg_Callback
51 /// Constructor sets whether we're testing "recursive" callback
53 Logger (bool be_recursive
= true);
56 void log (ACE_Log_Record
&log_record
) override
;
58 void verbose (bool be_verbose
);
61 /// Flag for testing verbose logging.
62 bool verbose_logging_
;
64 /// Flag for testing recursive callback logging.
69 Logger::verbose (bool be_verbose
)
71 this->verbose_logging_
= be_verbose
;
74 Logger::Logger (bool be_recursive
)
75 : recursive_ (be_recursive
)
80 Logger::log (ACE_Log_Record
&log_record
)
82 bool use_log_msg
= false;
85 this->recursive_
= false;
89 if (!this->verbose_logging_
)
93 ACE_TEXT ("Logger::log->%s\n"),
94 log_record
.msg_data ()));
96 #ifdef ACE_LACKS_IOSTREAM_TOTALLY
97 ACE_OS::fprintf (ace_file_stream::instance ()->output_file (),
98 "Recursive Logger callback = %s\n",
99 ACE_TEXT_ALWAYS_CHAR (log_record
.msg_data ()));
101 *ace_file_stream::instance ()->output_file ()
102 << "Recursive Logger callback = "
103 << log_record
.msg_data ()
105 #endif /* ACE_LACKS_IOSTREAM_TOTALLY */
109 ACE_TCHAR verbose_msg
[ACE_Log_Record::MAXVERBOSELOGMSGLEN
];
110 int result
= log_record
.format_msg (ACE_LOG_MSG
->local_host (),
111 ACE_LOG_MSG
->flags (),
113 ACE_Log_Record::MAXVERBOSELOGMSGLEN
);
117 ACE_DEBUG ((LM_DEBUG
,
118 ACE_TEXT ("Logger::log->%s\n"),
121 #ifdef ACE_LACKS_IOSTREAM_TOTALLY
122 ACE_OS::fprintf (ace_file_stream::instance ()->output_file (),
123 "Recursive Logger callback = %s\n",
124 ACE_TEXT_ALWAYS_CHAR (log_record
.msg_data ()));
126 *ace_file_stream::instance ()->output_file ()
127 << "Recursive Logger callback = "
128 << log_record
.msg_data ()
130 #endif /* ACE_LACKS_IOSTREAM_TOTALLY */
134 // Cleanup on the way out.
136 this->recursive_
= true;
142 // This message should show up in stderr.
143 ACE_DEBUG ((LM_DEBUG
,
144 ACE_TEXT ("(%t) first message\n")));
146 ACE_LOG_MSG
->clr_flags (ACE_Log_Msg::OSTREAM
);
148 // This message should not show up anywhere.
149 ACE_DEBUG ((LM_DEBUG
,
150 ACE_TEXT ("(%t) second message\n")));
152 ACE_LOG_MSG
->set_flags (ACE_Log_Msg::MSG_CALLBACK
);
154 // This message should not show up anywhere since no callback object
155 // has been specified.
156 ACE_DEBUG ((LM_DEBUG
,
157 ACE_TEXT ("(%t) third message\n")));
159 // Create a callback object and make it "verbose".
163 // Set the callback object.
164 ACE_LOG_MSG
->msg_callback (&logger
);
166 // This message should show up via the Logger callback.
167 ACE_DEBUG ((LM_DEBUG
,
168 ACE_TEXT ("(%t) forth message\n")));
170 ACE_LOG_MSG
->set_flags (ACE_Log_Msg::VERBOSE_LITE
);
172 // This message should show up via the Logger callback (somewhat
174 ACE_DEBUG ((LM_DEBUG
,
175 ACE_TEXT ("(%t) fifth message\n")));
177 ACE_LOG_MSG
->set_flags (ACE_Log_Msg::VERBOSE
);
179 // This message should show up via the Logger callback (really
181 ACE_DEBUG ((LM_DEBUG
,
182 ACE_TEXT ("(%t) sixth message\n")));
186 // This message should show up via the Logger callback (not
188 ACE_DEBUG ((LM_DEBUG
,
189 ACE_TEXT ("(%t) seventh message\n")));
191 ACE_LOG_MSG
->set_flags (ACE_Log_Msg::OSTREAM
);
193 // This message should show up in stderr and the Logger callback.
194 // The one from the Logger callback will not be verbose, but the one
195 // from stderr should be verbose.
196 ACE_DEBUG ((LM_DEBUG
,
197 ACE_TEXT ("(%t) eighth message\n")));
198 ACE_LOG_MSG
->msg_callback (0);
202 test_log_msg_features (const ACE_TCHAR
*program
)
204 // Note that the default behavior is to log to STDERR...
208 if (ACE_LOG_MSG
->open (program
) == -1)
209 ACE_ERROR ((LM_ERROR
,
210 ACE_TEXT ("cannot open logger!!!\n")));
214 // Check to see what happened.
215 if (ACE_LOG_MSG
->op_status () == -1
216 && ACE_LOG_MSG
->errnum () == EWOULDBLOCK
)
217 ACE_DEBUG ((LM_DEBUG
,
218 ACE_TEXT ("op_status and errnum work!\n")));
220 ACE_ERROR ((LM_ERROR
,
221 ACE_TEXT ("op_status and errnum failed!\n")));
223 const char *badname
= "badname";
225 // We use the DEBUG messages instead of error messages. This is to
226 // help the scripts. If we print out error messages the scripts
227 // start catching them as errors.
228 if (ACE_OS::open (badname
,
229 O_RDONLY
) == ACE_INVALID_HANDLE
)
230 ACE_DEBUG ((LM_DEBUG
,
231 ACE_TEXT ("%n: (%x), can't open %C%r\n"),
236 // Try a log operation that would overflow the logging buffer if not
238 ACE_TCHAR big
[ACE_Log_Record::MAXLOGMSGLEN
+ 1];
240 static const ACE_TCHAR alphabet
[] = ACE_TEXT ("abcdefghijklmnopqrstuvwxyz");
241 size_t j
= ACE_OS::strlen (alphabet
);
242 while (i
< ACE_Log_Record::MAXLOGMSGLEN
)
244 size_t const index
= i
++;
245 big
[index
] = alphabet
[i
% j
];
247 big
[ACE_Log_Record::MAXLOGMSGLEN
] = ACE_TEXT ('\0');
248 ACE_DEBUG ((LM_INFO
, ACE_TEXT ("This is too big:%l %s\n"), big
));
250 ACE_HEX_DUMP((LM_INFO
, (const char*)big
, ACE_Log_Record::MAXLOGMSGLEN
));
252 // Exercise many different combinations of OSTREAM.
254 double f
= 3.1416 * counter
++;
258 ACE_TEXT ("%10f, %*s%s = %d\n"),
265 ACE_LOG_MSG
->set_flags (ACE_Log_Msg::OSTREAM
);
266 ACE_LOG_MSG
->msg_ostream (ace_file_stream::instance ()->output_file ());
268 f
= 3.1416 * counter
;
269 n
= 10000 * counter
++;
272 ACE_TEXT ("%10f, %*s%s = %d\n"),
279 ACE_LOG_MSG
->clr_flags (ACE_Log_Msg::OSTREAM
);
281 // The next two messages shouldn't print.
283 f
= 3.1416 * counter
;
284 n
= 10000 * counter
++;
287 ACE_TEXT ("%10f, %*s%s = %d\n"),
294 f
= 3.1416 * counter
;
295 n
= 10000 * counter
++;
298 ACE_TEXT ("%10f, %*s%s = %d\n"),
305 ACE_LOG_MSG
->set_flags (ACE_Log_Msg::OSTREAM
);
307 f
= 3.1416 * counter
;
308 n
= 10000 * counter
++;
311 ACE_TEXT ("%10f, %*s%s = %d\n"),
318 static int array
[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048};
320 // Print out the binary bytes of the array in hex form.
321 ACE_LOG_MSG
->log_hexdump (LM_DEBUG
,
325 // Disable the LM_DEBUG and LM_INFO messages.
326 u_long priority_mask
=
327 ACE_LOG_MSG
->priority_mask (ACE_Log_Msg::PROCESS
);
328 ACE_CLR_BITS (priority_mask
,
330 ACE_LOG_MSG
->priority_mask (priority_mask
,
331 ACE_Log_Msg::PROCESS
);
334 ACE_TEXT ("This LM_INFO message should not print!\n")));
335 ACE_DEBUG ((LM_DEBUG
,
336 ACE_TEXT ("This LM_DEBUG message should not print!\n")));
338 ACE_SET_BITS (priority_mask
,
340 ACE_LOG_MSG
->priority_mask (priority_mask
,
341 ACE_Log_Msg::PROCESS
);
344 ACE_TEXT ("This LM_INFO message should print!\n")));
345 ACE_DEBUG ((LM_DEBUG
,
346 ACE_TEXT ("This LM_DEBUG message should not print!\n")));
348 ACE_CLR_BITS (priority_mask
, LM_INFO
);
349 ACE_LOG_MSG
->priority_mask (priority_mask
,
350 ACE_Log_Msg::PROCESS
);
353 ACE_TEXT ("This LM_INFO message should not print!\n")));
354 ACE_DEBUG ((LM_DEBUG
,
355 ACE_TEXT ("This LM_DEBUG message should not print!\n")));
358 // For testing how many log records has been output
359 class Log_Count
: public ACE_Log_Msg_Callback
364 Log_Count () : count_(0)
369 void log (ACE_Log_Record
&) override
381 test_acelib_category()
387 ACE_LOG_MSG
->msg_callback (&counter
);
389 // Disable the LM_DEBUG and LM_INFO messages.
390 u_long priority_mask
=
391 ACE_LOG_MSG
->priority_mask (ACE_Log_Msg::PROCESS
);
392 ACE_CLR_BITS (priority_mask
,
394 ACE_Log_Category::ace_lib().priority_mask (priority_mask
);
396 ACELIB_DEBUG ((LM_INFO
,
397 ACE_TEXT ("This LM_INFO message should not print!\n")));
398 ACELIB_DEBUG ((LM_DEBUG
,
399 ACE_TEXT ("This LM_DEBUG message should not print!\n")));
401 if (counter
.count() != 0)
407 ACE_TEXT ("This LM_INFO message should print!\n")));
408 ACE_DEBUG ((LM_DEBUG
,
409 ACE_TEXT ("This LM_DEBUG message should print!\n")));
411 if (counter
.count() != 2)
416 ACE_SET_BITS (priority_mask
,
418 ACE_Log_Category::ace_lib().priority_mask (priority_mask
);
420 ACELIB_DEBUG ((LM_INFO
,
421 ACE_TEXT ("This LM_INFO message should print!\n")));
423 if (counter
.count() != 3)
428 ACELIB_DEBUG ((LM_DEBUG
,
429 ACE_TEXT ("This LM_DEBUG message should not print!\n")));
431 if (counter
.count() != 3)
436 ACE_CLR_BITS (priority_mask
, LM_INFO
);
437 ACE_Log_Category::ace_lib().priority_mask (priority_mask
);
439 ACELIB_DEBUG ((LM_INFO
,
440 ACE_TEXT ("This LM_INFO message should not print!\n")));
441 ACELIB_DEBUG ((LM_DEBUG
,
442 ACE_TEXT ("This LM_DEBUG message should not print!\n")));
444 if (counter
.count() != 3)
451 ACE_DEBUG((LM_DEBUG
, "All ace lib category log passed\n"));
454 ACE_ERROR((LM_ERROR
, "Some ace lib category log failed\n"));
456 ACE_LOG_MSG
->msg_callback (0);
463 // This message should show up in the log file.
464 ACE_DEBUG ((LM_DEBUG
,
465 ACE_TEXT ("first message\n")));
467 ACE_LOG_MSG
->clr_flags (ACE_Log_Msg::OSTREAM
);
469 // This message should not show up anywhere.
470 ACE_DEBUG ((LM_DEBUG
,
471 ACE_TEXT ("second message\n")));
473 ACE_LOG_MSG
->set_flags (ACE_Log_Msg::OSTREAM
);
475 #if !defined (ACE_LACKS_IOSTREAM_TOTALLY)
476 // Create a persistent store.
477 const ACE_TCHAR
*filename
= ACE_TEXT ("output");
478 ofstream
myostream (ACE_TEXT_ALWAYS_CHAR (filename
), ios::out
| ios::trunc
);
481 if (myostream
.bad ())
484 OFSTREAM
*old_stream
= ace_file_stream::instance ()->output_file ();
486 ACE_LOG_MSG
->msg_ostream (&myostream
);
488 // This message should show up in the ostream.
489 ACE_DEBUG ((LM_DEBUG
,
490 ACE_TEXT ("fourth message\n")));
491 // Set the ostream back to the test's log file.
492 ACE_LOG_MSG
->msg_ostream (old_stream
);
493 // Now close the ostream file and check its contents.
496 ACE_FILE_Connector connector
;
498 ACE_FILE_Addr
file_addr (filename
);
501 if (connector
.connect (file
, file_addr
) == -1)
503 ACE_ERROR_RETURN ((LM_ERROR
,
504 ACE_TEXT ("connect failed for %p\n"),
509 #if !defined (ACE_VXWORKS) || (defined(ACE_VXWORKS) && (ACE_VXWORKS > 0x690))
510 # define TEST_CAN_UNLINK_IN_ADVANCE
513 #if defined (TEST_CAN_UNLINK_IN_ADVANCE)
514 // Unlink this file right away so that it is automatically removed
515 // when the process exits.Ignore error returns in case this operation
517 ACE_OS::unlink(filename
);
521 if (file
.get_info (info
) == -1)
523 ACE_ERROR_RETURN ((LM_ERROR
,
524 ACE_TEXT ("get_info failed on %p\n"),
529 // Allocate the input buffer
531 ACE_NEW_RETURN (buffer
,
532 char[info
.size_
+ 1],
534 // Make sure <buffer> is released automagically.
535 std::unique_ptr
<char[]> b (buffer
);
537 // Read the file into the buffer.
538 ssize_t size
= file
.recv (buffer
,
540 if (size
!= info
.size_
)
542 ACE_ERROR_RETURN ((LM_ERROR
,
543 ACE_TEXT ("Read %d bytes, rather than expected %d bytes\n"),
548 // Make sure to NUL-terminate this turkey!
552 ACE_DEBUG ((LM_DEBUG
,
556 #if !defined (TEST_CAN_UNLINK_IN_ADVANCE)
558 if (file
.unlink () == -1)
559 ACE_ERROR_RETURN ((LM_ERROR
,
560 ACE_TEXT ("unlink failed for %p\n"),
561 file_addr
.get_path_name ()),
565 #endif /* ACE_LACKS_IOSTREAM_TOTALLY */
567 // This message should show up in stderr and the ostream (without
568 // ACE_LACKS_IOSTREAM_TOTALLY).
569 ACE_DEBUG ((LM_DEBUG
,
570 ACE_TEXT ("fifth message\n")));
576 // For testing the format specifiers, a class is defined as a callback
577 // mechanism. It will get the formatted messages and check them for
578 // correctness. The test_format_specs() function will set the first
579 // few characters to say which test is being run, and the Log_Spec_Verify
580 // class will use that to decide how to verify the results.
582 class Log_Spec_Verify
: public ACE_Log_Msg_Callback
585 Log_Spec_Verify (bool be_recursive
= true) : fail_ (0), tests_ (0), recursive_ (be_recursive
) {};
588 void log (ACE_Log_Record
&log_record
) override
;
593 /// Count how many tests failed.
596 /// Count how many tests we run
603 Log_Spec_Verify::log (ACE_Log_Record
&log_record
)
605 bool use_log_msg
= false;
606 if (this->recursive_
)
608 this->recursive_
= false;
614 #if !defined (ACE_LACKS_IOSTREAM_TOTALLY)
615 *ace_file_stream::instance ()->output_file ()
616 << "Logger callback = "
617 << log_record
.msg_data ()
619 #endif /* ACE_LACKS_IOSTREAM_TOTALLY */
623 const ACE_TCHAR
*b
= log_record
.msg_data ();
624 const ACE_TCHAR
*expect
= 0;
628 if (ACE_OS::strncmp (b
, ACE_TEXT ("l1:"), 3) == 0)
630 expect
= ACE_TEXT ("42");
633 else if (ACE_OS::strncmp (b
, ACE_TEXT ("l2:"), 3) == 0)
635 expect
= ACE_TEXT (" 42");
638 else if (ACE_OS::strncmp (b
, ACE_TEXT ("l3N1:"), 4) == 0)
640 expect
= ACE_TEXT ("0042,Log_Msg");
643 else if (ACE_OS::strncmp (b
, ACE_TEXT ("l4:"), 3) == 0)
646 // Check if we have a string, exact length could vary
647 if (b
!= log_record
.msg_data () && ACE_OS::strlen (b
) < 15)
649 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("ERROR: Test %s failed; expected %d\n"),
650 log_record
.msg_data (), ACE_OS::strlen (b
)));
654 else if (ACE_OS::strncmp (b
, ACE_TEXT ("l5:"), 3) == 0)
657 switch (log_record
.type())
659 case (LM_SHUTDOWN
): expect
= ACE_TEXT("S"); break;
660 case (LM_TRACE
): expect
= ACE_TEXT("T"); break;
661 case (LM_DEBUG
): expect
= ACE_TEXT("D"); break;
662 case (LM_INFO
): expect
= ACE_TEXT("I"); break;
663 case (LM_NOTICE
): expect
= ACE_TEXT("N"); break;
664 case (LM_WARNING
): expect
= ACE_TEXT("W"); break;
665 case (LM_STARTUP
): expect
= ACE_TEXT("U"); break;
666 case (LM_ERROR
): expect
= ACE_TEXT("E"); break;
667 case (LM_CRITICAL
): expect
= ACE_TEXT("C"); break;
668 case (LM_ALERT
): expect
= ACE_TEXT("A"); break;
669 case (LM_EMERGENCY
): expect
= ACE_TEXT("!"); break;
670 default: expect
= ACE_TEXT("?"); break;
673 else if (ACE_OS::strncmp (b
, ACE_TEXT ("l6:"), 3) == 0)
675 // After a l6 there shouldn't be a space
677 if (b
!= log_record
.msg_data () && ACE_OS::strncmp (b
, ACE_TEXT (" "), 1) == 0)
679 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("ERROR: Test %s failed; expected no space before the time\n"),
680 log_record
.msg_data ()));
686 ACE_ERROR ((LM_ERROR
,
687 ACE_TEXT ("Log_Spec_Verify, unrecognized test: %s\n"),
692 if (b
!= log_record
.msg_data () && expect
&& ACE_OS::strcmp (b
, expect
) != 0)
694 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("ERROR: Test %s failed; expected %s\n"),
695 log_record
.msg_data (), expect
));
700 // Cleanup on the way out.
702 this->recursive_
= true;
706 Log_Spec_Verify::result ()
708 if (this->fail_
== 0)
709 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("All logging specifier tests passed.\n")));
711 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("%d logging specifier tests failed!\n"),
714 if (this->tests_
!= 19)
716 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("Expected number of tests run is %d, not 19!\n"),
726 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("l1:%l\n")));
727 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("l2:%5l\n")));
728 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("l3N1:%0*l,%.7N\n"), 4));
729 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("%*ISTART INDENTING %{\n"), 4));
730 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("%IONE%{\n")));
731 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("%ITWO%{\n")));
732 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("%ITHREE%*Iwp == 1\n"), 1));
733 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("%}%ITWO\n")));
734 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("%}%IONE\n")));
735 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("%}%IENDINDENTING\n")));
736 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("%W\n"), ACE_TEXT_WIDE ("My string test\n")));
737 ACE_WCHAR_T
*nill_string
= 0;
738 char* char_nill_string
= 0;
739 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("%W\n"), nill_string
));
740 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("%s\n"), nill_string
));
741 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("%C\n"), char_nill_string
));
742 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("%m %p\n"), nill_string
));
744 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("%m %p\n"), ACE_TEXT("perror")));
745 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("%S\n"), SIGINT
));
746 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("%S\n"), ACE_NSIG
));
747 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("thread id %t\n")));
749 Log_Spec_Verify verifier
;
751 ACE_LOG_MSG
->msg_callback (&verifier
);
752 ACE_LOG_MSG
->clr_flags (ACE_Log_Msg::VERBOSE_LITE
);
753 ACE_LOG_MSG
->clr_flags (ACE_Log_Msg::VERBOSE
);
754 ACE_LOG_MSG
->linenum (42);
755 ACE_LOG_MSG
->file ("Log_Msg_Test.cpp");
757 #ifdef ACE_LACKS_VA_FUNCTIONS
760 #define LOG_ARGS(X) X
763 ACE_LOG_MSG
->log
LOG_ARGS ((LM_DEBUG
, ACE_TEXT ("l1:%l")));
764 ACE_LOG_MSG
->log
LOG_ARGS ((LM_DEBUG
, ACE_TEXT ("l2:%5l")));
765 ACE_LOG_MSG
->log
LOG_ARGS ((LM_DEBUG
, ACE_TEXT ("l3N1:%0*l,%.7N"), 4));
766 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("l4:%T")));
768 ACE_LOG_MSG
->priority_mask (LM_SHUTDOWN
|
779 ACE_Log_Msg::PROCESS
);
780 ACE_DEBUG ((LM_SHUTDOWN
, ACE_TEXT ("l5:%.1M")));
781 ACE_DEBUG ((LM_TRACE
, ACE_TEXT ("l5:%.1M")));
782 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("l5:%.1M")));
783 ACE_DEBUG ((LM_INFO
, ACE_TEXT ("l5:%.1M")));
784 ACE_DEBUG ((LM_NOTICE
, ACE_TEXT ("l5:%.1M")));
785 ACE_DEBUG ((LM_WARNING
, ACE_TEXT ("l5:%.1M")));
786 ACE_DEBUG ((LM_STARTUP
, ACE_TEXT ("l5:%.1M")));
787 ACE_DEBUG ((LM_ERROR
, ACE_TEXT ("l5:%.1M")));
788 ACE_DEBUG ((LM_CRITICAL
, ACE_TEXT ("l5:%.1M")));
789 ACE_DEBUG ((LM_ALERT
, ACE_TEXT ("l5:%.1M")));
790 ACE_DEBUG ((LM_EMERGENCY
, ACE_TEXT ("l5:%.1M")));
792 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("l6:%D\n")));
793 ACE_Time_Value tv
= ACE_OS::gettimeofday ();
794 tv
+= ACE_Time_Value (25*60*60); // + 25 hours
795 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("l6:%#D\n"), &tv
));
797 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("l6:%T\n")));
798 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("l6:%#T\n"), &tv
));
800 ACE_LOG_MSG
->msg_ostream (ace_file_stream::instance ()->output_file ());
801 ACE_LOG_MSG
->msg_callback (0);
802 ACE_LOG_MSG
->set_flags (ACE_Log_Msg::OSTREAM
);
803 ACE_LOG_MSG
->set_flags (ACE_Log_Msg::VERBOSE_LITE
);
805 return verifier
.result ();
811 run_main (int argc
, ACE_TCHAR
*argv
[])
813 ACE_START_TEST (ACE_TEXT ("Log_Msg_Test"));
817 ACE_DEBUG ((LM_DEBUG
,
818 ACE_TEXT ("**** running ostream test\n")));
820 // Test the <ACE_Log_Msg> abstraction wrt writing to stderr and to a
824 ACE_DEBUG ((LM_DEBUG
,
825 ACE_TEXT ("%M **** running callback test\n")));
827 // Test the <ACE_Log_Msg> callback mechanism.
830 ACE_DEBUG ((LM_DEBUG
,
831 ACE_TEXT ("**** running features test\n")));
833 // Test various features of the <ACE_Log_Msg>.
834 test_log_msg_features ((argc
> 0 ? argv
[0] : ACE_TEXT ("program")));
836 // Test the format specifiers
838 // Restore this mask so diags and the shutdown message will print correctly!
839 ACE_LOG_MSG
->priority_mask (ACE_LOG_MSG
->priority_mask () | LM_DEBUG
| LM_ERROR
,
840 ACE_Log_Msg::PROCESS
);
842 ACE_DEBUG ((LM_DEBUG
,
843 ACE_TEXT ("**** running format specifiers test\n")));
845 if (status
+= test_format_specs ())
847 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("logging specifier tests failed!\n")));
851 status
+= test_acelib_category();