2 //=============================================================================
4 * @file test_ostream.cpp
6 * This program tests the Log_Msg abstraction wrt writing to
7 * stderr and to a file.
9 * @author Irfan Pyarali <irfan@cse.wustl.edu>
11 //=============================================================================
14 #include "ace/OS_main.h"
16 // FUZZ: disable check_for_streams_include
17 #include "ace/streams.h"
19 #include "ace/Log_Msg.h"
23 ACE_TMAIN (int, ACE_TCHAR
*[])
25 // This message should show up in stderr.
29 ACE_LOG_MSG
->clr_flags (ACE_Log_Msg::STDERR
);
31 // This message should not show up anywhere.
35 ACE_LOG_MSG
->set_flags (ACE_Log_Msg::OSTREAM
);
37 // This message should not show up anywhere since no ostream has
42 #if !defined (ACE_LACKS_IOSTREAM_TOTALLY)
43 // Create a persistent store.
44 const char *filename
= "output";
45 ofstream
outfile (filename
, ios::out
| ios::trunc
);
52 ACE_LOG_MSG
->msg_ostream (&outfile
);
54 // This message should show up in the ostream.
57 #endif /* ACE_LACKS_IOSTREAM_TOTALLY */
59 ACE_LOG_MSG
->set_flags (ACE_Log_Msg::STDERR
);
61 // This message should show up in stderr and the ostream (without
62 // ACE_LACKS_IOSTREAM_TOTALLY).
66 #if !defined (ACE_LACKS_IOSTREAM_TOTALLY)
67 ifstream
infile (filename
, ios::in
);
72 // This loop should print out the contents of file "output", which should
73 // have the strings "fourth\n" and "fifth\n" in them.
77 while (infile
.getline (line
, BUFSIZ
, '\n'))
78 std::cout
<< line
<< std::endl
;
80 #endif /* ACE_LACKS_IOSTREAM_TOTALLY */