Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / examples / Log_Msg / test_ostream.cpp
blobae6b9e9bd2b1e7ff1b548c8e723f711d2d79bd16
2 //=============================================================================
3 /**
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"
22 int
23 ACE_TMAIN (int, ACE_TCHAR *[])
25 // This message should show up in stderr.
26 ACE_DEBUG ((LM_DEBUG,
27 "first message\n"));
29 ACE_LOG_MSG->clr_flags (ACE_Log_Msg::STDERR);
31 // This message should not show up anywhere.
32 ACE_DEBUG ((LM_DEBUG,
33 "second message\n"));
35 ACE_LOG_MSG->set_flags (ACE_Log_Msg::OSTREAM);
37 // This message should not show up anywhere since no ostream has
38 // been specified.
39 ACE_DEBUG ((LM_DEBUG,
40 "third message\n"));
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);
47 // Check for errors.
48 if (outfile.bad ())
49 return 1;
51 // Set the ostream.
52 ACE_LOG_MSG->msg_ostream (&outfile);
54 // This message should show up in the ostream.
55 ACE_DEBUG ((LM_DEBUG,
56 "fourth message\n"));
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).
63 ACE_DEBUG ((LM_DEBUG,
64 "fifth message\n"));
66 #if !defined (ACE_LACKS_IOSTREAM_TOTALLY)
67 ifstream infile (filename, ios::in);
69 if (infile.bad ())
70 return 1;
72 // This loop should print out the contents of file "output", which should
73 // have the strings "fourth\n" and "fifth\n" in them.
75 char line[BUFSIZ];
77 while (infile.getline (line, BUFSIZ, '\n'))
78 std::cout << line << std::endl;
80 #endif /* ACE_LACKS_IOSTREAM_TOTALLY */
81 return 0;